Java review --- the difference between threads and operating system threads

When threads are implemented in user space, the operating system is unaware of the existence of threads. The operating system can only see the process but not the threads. All threads are implemented in user space.

In other words, programmers need to implement thread data structure, creation, destruction, and scheduling maintenance by themselves. It is equivalent to the need to implement its own thread scheduling kernel.

Threads in Java

Before JDK1.2, the JVM had its own thread scheduling kernel, and at the operating system level, it was the thread implementation in the user space.

After 1.2, the JVM was replaced with the native thread model of the operating system, and the threads of the program were handed over to the operating system kernel for scheduling through system calls. In other words, the essence of Java threads is the threads in the operating system. Under Linux, it is a lightweight process realized by pthread, and under Windows, it realizes multithreading through system calls provided by win32 API.

Guess you like

Origin blog.csdn.net/why1092576787/article/details/114702927