954,123 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

kill parent and retain child process?

Is there anyway to create a new thread..basically create an object of a class within an existing thread and kill this existing thread so only the newly created child remains?

uth
Newbie Poster
4 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

uth,

You can create a new thread at any time. Then if you so desire, let the 'main' thread die by letting the 'public static main' function return. If the thread you created is a 'daemon' thread the JVM will exit all together. However if the thread you created was a 'user' thread the JVM will not exit straight away, instead another thread will be automatically created called 'DestroyJavaVM' which will wait until all 'user' threads return and then kill the JVM. But why would you want to do this, one thread is as good as any other.

Kate

Kate Albany
Junior Poster in Training
71 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

Hi Kate,

What I need to do is have another instance of the same class running and shut down the existing instance. Will try what you suggested today!Thanks!

uth,

You can create a new thread at any time. Then if you so desire, let the 'main' thread die by letting the 'public static main' function return. If the thread you created is a 'daemon' thread the JVM will exit all together. However if the thread you created was a 'user' thread the JVM will not exit straight away, instead another thread will be automatically created called 'DestroyJavaVM' which will wait until all 'user' threads return and then kill the JVM. But why would you want to do this, one thread is as good as any other.

Kate

uth
Newbie Poster
4 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

hi!!
i wanna ask did u find any solution of below situation. Actually i want to do erxactly the same, kill the exixting thread before creating new thread.

Thx
Hi Kate,

What I need to do is have another instance of the same class running and shut down the existing instance. Will try what you suggested today!Thanks!

sgul
Newbie Poster
1 post since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You