Daemon thread
Thread classification can be divided into:User thread(above They are all about user threads), and the other isdaemon thread. The daemon thread is like this. When all user threads end their life cycle, the daemon thread will end its life cycle. As long as there is one user thread, the daemon thread will not end. For example, the famousGarbage Collector## in Java #It is a daemon thread. It will not end until all threads in the application end.
(Free learning recommendation:java basic tutorial)
User thread
Modify it to a daemon (service thread) thread
##After setting it as a daemon thread, When the main thread ends, the daemon thread does not end after outputting all the data. In other words, the daemon thread serves
When all user threads end, the daemon thread will Automatically endTimer Timer
[Code example], use anonymous classes to implement the above Function
Quartz
window
##TimerFocus on mastering
The concepts of processes and threads
Threads Two implementation methods
Thread,Runnable)Understand the priority of the thread
The above is the detailed content of Java zero-based detailed explanation of multi-threading. For more information, please follow other related articles on the PHP Chinese website!