hi David
thanks for your suggestion. i would try to read the link you provided and see how can i improve on things. yeah i agree, i'm a bad presenter
i guess its time to cut off on these chatting arena short forms
anyways,
well, the thread code is in the separate file and i pass appropriate arguments to the thread when i create one so i guess its not in the servlet if thats what you meant.
the problem in the first approach where i use Runtime.exec() was that the process that was getting forked was going into sleep mode after sometime and never was getting awakened and my application was getting screwed up.
When we use Runtime.exec() then we have to read in the output from the process (or error stream) to make sure it was completed. Also we should call process.waitFor() may be. Now, if i have to do that then the problem of browser proxy timeout can't be solved as i would wait for response from the process forked by Runtime.exec() which takes time. So, i basically fork parallel thread and respond to the user that they are done. well, this is kind of cheating but it is better than getting headaches in production system as a result of browser proxy timeout.
Hope I am able to explain my position here.
About the cleanup code you asked me, I guess I need cleanup code because otherwise if the servlet gets unloaded by the webserver somehow then the threads will stray around and all you know. So, to avoid that I am putting all the forked thread in a list and then on destroy() I am making sure every thread on the list was completed. Well, this is what I remember from Oreilly book or something that cautioned me about using threads in servlet as the servlet is also managed by threads by the webserver.
Also, I am scared as usually people recommend not to spawn a thread in a servlet. Though I have not any substantial argument to support my fear.
Also, please forgive me for still lower case letters at many places instead of upper case but you know it will take couple of posts before I learn. I was there in some earlier thread discussing the weirdness with which people write posts and I guess this is my last post where you would find weiredness in writing.
Regards
Maulin.