dcsimg
Create a thread.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Eric_Chow
Posted On:   Sunday, July 7, 2002 06:35 AM


			
Hello,

Is it possible to create a Thread to run in background but the parent will be exit ?

This is like the fork() in C.

I want to in the parent program to create a Thread to handle something, the thread will be end after finish the job and the parent program will be ended immediately after create the thread.

Would you please to give me a simple example ?

Best regards,
Eric


Re: Create a thread.

Posted By:   Eric_Lindauer  
Posted On:   Tuesday, July 16, 2002 05:51 PM

Hi,

You may be looking for the Runtime.getRuntime ().exec () method(s). These create a new process which will run even if the original JVM exits, and will not hold up the original thread ( though you may call the process.wait () method if you do want to wait it out before continuing... ).






If you are really looking for a Thread that won't hold up the original Thread, any will do. The start () method in thread returns (almost) immediately, and then in a different thread the run method of the new Thread is called. The parent and child will then execute in parallel.





Hope this helps.

-Eric
About | Sitemap | Contact