This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
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
deekasha gunwant
Ranch Hand
Joined: May 06, 2000
Posts: 396
posted
0
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).]
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
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
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.