Java Memory Model and Threads (6): Java and Threads

We know that a thread is the basic unit of CPU scheduling.

There are three ways of thread implementation: using kernel thread implementation, using user thread implementation, and using user thread plus lightweight process hybrid implementation.

Thread scheduling is mainly divided into cooperative thread scheduling and preemptive thread scheduling.

Java's thread scheduling is mainly preemptive thread scheduling. 

The Java language defines five thread states:

New: A thread that has not been started after creation is in this state.

Running: also hungry corresponds to Running and Readdy in the operating system state.

Waiting indefinitely: this state will not be allocated CPU execution time and requires other threads to display wake-up

Deadline waiting: This state will not be allocated CPU execution time and does not require other threads to wake up

Blocked state: the thread is blocked

End: The thread state that has been terminated.

The following figure is the thread state transition relationship


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325721806&siteId=291194637