hello, Can anybody pls tell me the difference between daemon and user threads? How daemon thread is useful during execution of prog. What's the priority of daemon thread? Does it belongs to ThreadGroup?
a daemon thread is generally a thread running in the background. The threads you create in a program are user threads unless you specify otherwise. I'm not sure the priority of a daemon thread. If there is one, I'd imagine it's pretty low.
Daemon threads will not prevent the VM from exiting. Once all work in non-daemon threads is complete (the runs have returned), the VM will exit - so a daemon thread is most suitable for continuous tasks that support primary functions (like GC, lock sweeping, connection time-outs, etc.)
The daemon thread, except that it is managed by JVM and will get killed if no user threads are running, is also just another thread. Therefore, just like normal threads, they will have the priority of the creating thread and the value Thread.NORM_PRIORITY by default. They will belong to the same ThreadGroup as their parent thread, unless explicitly created as belonging to another ThreadGroup using the overloaded Thread constructor. Infact you can set the entire ThreadGroup as daemon. Any threads that belong to that ThreadGroup will be marked as daemon too.
------------------ Ajith Kallambella M. Sun Certified Programmer for the Java�2 Platform. IBM Certified Developer - XML and Related Technologies, V1.
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).