How do I make a background thread in Java that allows the main application to exit completely? This

Posted by Bob on Stack Overflow See other posts from Stack Overflow or by Bob
Published on 2010-04-14T23:02:31Z Indexed on 2010/04/14 23:03 UTC
Read the original article Hit count: 229

Filed under:
|
|
|

I have a Java application that creates a new thread to do some work. I can launch the new thread with no problems.

When the "main" program terminates, I want the thread I created to keep running - which it does...

But the problem is, when I run the main application from Eclipse or from Ant under Windows, control doesn't return unless the background process is killed.

If I fork the main java process in ant, I want control to return to ant once the main thread is done with its work... But as it is, ant continues to wait until both the main process and the created thread are both terminated.

How do I launch the thread in the background such that control will return to ant when the "main" application is finished? (By the way, when I run the same application under Linux, I am able to do this with no problems).

© Stack Overflow or respective owner

Related posts about java

Related posts about thread