Hi Dinesh,
I must admit I didn't tried the example, I just got inspiration from the SampleClient.java code in order to write my own mutlithread code...
But after a quick look, it seems that the problem is because a script tries to refer to a document created in another thread.
I think the problem is because all scripts in the example (addtextFrame1, addtextFrame2, saveclose1, saveclose2) refer to app.documents[0].
But app.documents[0] is created in thread 1...
Try to change to app.documents[1] for the scripts addtextFrame2 and saveclose2.
In general, it is your responsibility to verify that you access the proper document, I would advise sending the document name as a script argument to be sure, and never use app.documents[x]
I hope that will solve your problem,
/Martin