Can anyone explain me then exact difference between a user thread and a daemon thread Thanks in advance
SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
Joined: May 06, 2000
hi gaurav, here is what i know - an application runs untill all its thread die. sometimes however u may need some threads to perform the cleanup or maintenance tasks that never terminate. you can run such a task in a thread and flag it as a dameon thread. which tells the java virtual machine to to ignore the thread when it cheks whether all threads have terminated. in other words a java program runs until all its no dameon die. non dameon threads are called user threads. - any thread can be made dameon thread by using method setDameon(true). or u can enquire about a thread's status by using function isDaemon(); - as soon as all the user threads die the application terminates & kills all the dameon threads. irrespective of the state or the work that thread is doing. - so think twice before u put a task in a thread and declare that thread a dameon thread. coz it can die any time if the all the user threads die. - All the threads iinitiated by a dameon thread will be dameon. & all initiated by user thread will be user threads.
this is what i know now. i'm reading about it & will post any other thing i come to know hope same from ur side regards deekasha
[This message has been edited by deekasha gunwant (edited June 22, 2000).]
Joined: Nov 22, 2008
please look for a prior post pretaining to user vs deamon threads with the las 15 days. it contains a programs examples that you might find useful. Monty6