Asynchronous thread execution from servlet

hii,

I have a servlet from which I m creating a thread. I want to execute the thread even if it completes servlet execution. For ex. I have a servlet UserServlet from which I m creating a thread RunApplication. I want to run RunApplication even if the UserServlet completes its execution..

Please help me...

Thanks in advance...

[354 byte] By [Anoop_KAa] at [2007-11-27 9:36:36]
# 1
Just start it .. ?I don't see a concrete question nor the actual problem you're occurring while accomplihing the task .. Can you please elaborate the question or problem?
BalusCa at 2007-7-12 23:06:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanks for the support..

I will try to explain in detail..

My real problem is I have a web page from which displays a user details includes phone number. There is a dial is present in the page. On clicking the dial button it invokes a servlet UserManagerServlet. I am creating an object of CallMaker which is responsible for performing the call functionality. The CallMaker class have a dial method which performs the call. There is a listener callListener which extends the class Thread and overrides the run method as

try {

while(onCall) Thread.sleep(500);

} catch (InterruptedException e) {

e.printStackTrace();

}

The object of callListener is created from CallMaker .

If I m Adding callListner.join(); from CallMaker class The servlet waits until this thread completes its execution.

My problem is I DONT WANT to wait the servlet until the thread completes execution. The servlet should send the response immediately. And also the

CallListener should CONTINUE execution even if the servlet completes execution and send the response back to the client...

Is it possible to do?..

Sorry If I m not explained properly...

Thanks

Anoop_KAa at 2007-7-12 23:06:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Well, you've found the cause: you're joining the thread (which means: you're waiting for the thread to die). Why do you want to join the thread anyway? To do it asynchronously you should 'fire and forget' a Thread from the servlet and let the thread maintain it's own state. You may need to run CallMaker as a Thread.

BalusCa at 2007-7-12 23:06:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
But if I m not using join the thread callListener dies.......as the servlet completesexecutionThe callListener is running as a Thread.
Anoop_KAa at 2007-7-12 23:06:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

> The callListener is running as a Thread.

I didn't mean that. Right now your servlet creates a CallMaker object which on it's turn waits for all CallListener threads to be died. Instead you need to run a separate thread which creates a CallMaker object, and *not* to join that CallMaker thread.

BalusCa at 2007-7-12 23:06:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...