The guardian thread is a convenient thread for the operation of other threads. The guardian thread does not prevent the termination of the program.
Some implementations of Java's garbage collection mechanism use daemons.
Non-laid threads include conventional user threads or event scheduling threads for processing GUI events.
The program can include a daemon and a non-daemon.
When the program only has a guarding thread, the program can end running.
If you want a thread to be a daemon, you must make settings before calling its START method (by calling the thread as the parameter to call the thread), you can define the thread as a daemon, otherwise IllegalthReadStateException is thus thus. If the thread is a daemon, the IsDaemon method returns true.
Note: 1. If after the thread has been started, try to make the thread become a daemon, it will cause the IllegalthReadStateException.
2, the event scheduling thread is an infinite loop thread, not a daemon. Thus, the event scheduling thread will not terminate before the EXIT method of the SYSTEM class is called based on the window-based application.
3. You cannot assign key tasks to the daemon. These tasks will be terminated in advance without warning, which can cause it to complete them correctly.