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).
Your best bet is to launch a completely independent program for that, which is independent from the launching program. You can do that with Runtime#exec()
, ProcessBuilder
or Desktop#open()
.