Third-party Stop Threads:
It turns out to be stop (), because the method has some problems, so it is replaced by the interrupt () method, its use and mechanism is
When the frozen thread is not specified to return to the running state, the freeze needs to be purged, forcing the thread to return to the running state, which allows the action tag to end the thread.
The thread class provides the interrupt () method.
Daemon Thread:
The thread object. Setdaemon (); This method means that the foreground thread (the main thread) ends and the background thread (the background running thread) ends immediately.
Join method:
Waits for the thread to terminate. That is, when the main thread is running, it reads the beginning of the threads, that is, after start () and then the join () method, then it represents the thread request to join the run, that is,
The thread wants the CPU to execute the power. , robbing the CPU of executive power. The main thread at this time is in a frozen state, and when the thread executes, the mainline friend gets execution.
PS: When a thread executes the. Join () method to the B-thread, a waits. When the b thread is executed, a will not execute.
join can be used to temporarily join thread execution. at the same time, when the B thread has an await, the interrupt method should be used.
Multithreading---Other ways to stop threads, daemon threads, join methods