Thread state transitions in Java:
Note: Start execution immediately after start, just ready (the CPU may be running other threads).
"Note": Only after the CPU is dispatched, the thread will start executing, and when the CPU is allocated to your time slice, and back to the ready state, continue to wait in line.
The basic method of threading control:
IsAlive (): Determine if the thread is still alive, start, and before the termination is alive;
GetPriority (): Gets the priority number of the thread;
SetPriority (): Sets the priority number of the thread (the thread roommate priority level);
Thread.Sleep (): Specifies the number of milliseconds to sleep on the current thread;
Join (): Calls the method of a thread, merges the current thread with the thread, waits for the thread to end, and then resumes the current thread's running state (for example, thread A's join () method is called in Threads B until thread a finishes executing, and then thread B is resumed);
Yield (): The current thread out of the CPU, into a ready state, waiting for the CPU to dispatch again;
Wait (): The current thread enters the object's wait pool;
Notify ()/notifyall (): Wakes up one/all waiting threads in the wait pool of the object.
1. Sleep () Method:
① can invoke the static method of Thread:
public static void sleep(long Millis) throws Interruptedexception: Allows the currently executing thread to hibernate (suspend execution) within the specified number of milliseconds. This operation is affected by the accuracy and accuracy of the system timer and scheduler, and the thread does not lose ownership of any monitors.
② because it is a static method, sleep () can be called directly by the class name.
Thread.Sleep (...);
Common methods for threading state transitions and threading control in Java