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
As can be seen from the above, the main thread execution has ended, but the user thread still prints the dataModify 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
user threads.When all user threads end, the daemon thread will Automatically endTimer Timer
##The above program will be output at 2010-02-20 15:23:10, and output once every 24 hours
[Code example], use anonymous classes to implement the above Function
The above program will output at 2010-02-20 15:29:10, once every 2 seconds. There are special third-party open source products about the schedule, such as :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!