Daemon threads and native threads difference in java

java threads in two types: a daemon thread (Daemon) and user thread (User).
Any thread can be set to the user daemon thread and the thread, by the method Thread.setDaemon (boolon); true put the thread is a daemon thread is provided, and vice versa for the user thread. Thread.setDaemon () must be called () before Thread.start, otherwise it will throw an exception at runtime.
Difference between the two:
The only difference is that the virtual machine (JVM) when to leave, Daemon is to provide services to other threads, if all of the User Thread have been evacuated, Daemon thread is not serviceable, JVM evacuation. Can also be understood as guardian of the JVM thread is the thread created automatically (but not necessarily), the user thread is a thread program created; such as the JVM's garbage collection thread is a daemon thread, when all the threads have been evacuated, no longer produces garbage, daemon thread naturally, nothing can be done, when the garbage collector thread is the only remaining thread on the Java virtual machine, Java virtual machines are automatically leave.
Extended: Thread Dump print out the thread information, the thread containing the words daemon is the daemon, there may be: service daemon, compiled daemon listens at the windows + Ctrl daemon break in, Finalizer daemon process references guard process, GC daemon.

Guess you like

Origin www.cnblogs.com/fishness/p/12306064.html