| Forums.Sureshkumar.net : A Perfect Place to Share Knowledge Blogs Games Magazines |
|
|
#2 (permalink) |
|
Senior Member
Join Date: Dec 2006
Posts: 698
Thanks: 3 Thanked 15 Times in 12 Posts Thanks: 3
Thanked 15 Times in 12 Posts
Rep Power: 10
|
Re: Daemon Thread
Hi,
In java we have two type of Threads : Daemon Thread and User Threads. Generally all threads created by programmer are user thread (unless you specify it to be daemon or your parent thread is a daemon thread). User thread are generally meant to run our programm code. JVM doesn't terminates unless all the user thread terminate. On the other hand we have Daemon threads. Typically these threads are service provider threads. They should not be used to run your program code but some system code. These thread run paralley to your code but survive on the mercy of the JVM. When JVM finds no user threads it stops and all daemon thread terminate instantly. Thus one should never rely on daemon code to perform any program code. For better understanding consider a well known example of Daemon thread : Java garbage collector. Garbage collector runs as a daemon thread to recalim any unused memory. When all user threads terminates, JVM may stop and garbage collector also terminates instantly. Regards, Abeetha.M |
|
|
|
|
|
#3 (permalink) |
|
Senior Member
Join Date: Oct 2006
Posts: 426
Thanks: 10 Thanked 29 Times in 25 Posts Thanks: 10
Thanked 29 Times in 25 Posts
Rep Power: 12
|
Re: Daemon Thread
Daemon threads are service providers for othet threads or objects.a daemon thread executes continously.It generally provides a background processing.
to make a thread as daemon thread t.setDaemon(true); to know if a thread is a daemon or not boolean x=t.isDaemon(); |
|
|
|
| The Following User Says Thank You to jasmine84 For This Useful Post: |
sk_kireeti (13-12-06)
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Thread class Vs Runnable interface | Sudhan | JAVA Technologies | 5 | 24-09-08 08:10 PM |
| thread - join() | anitha.s | JAVA Technologies | 2 | 29-01-07 11:42 AM |
| OOPS No Thread for AS 400 | shahaan | OTHERS | 0 | 15-10-06 03:13 AM |
| Round Robin Algo. | WISDOM | NETWORK ADMINISTRATION , HARDWARE & TROUBLESHOOTING | 9 | 17-08-06 08:06 PM |
| Java Contest-7 with answers | keerthi | JAVA Technologies | 11 | 26-03-06 03:06 AM |