Java multi-native underlying thread implementation --Thread

Java multi-threading

  • When we went to read the java Thread class, you will find this class and most of the java API library there is a clear difference in all of its key methods are declared Native .
  • native itself refers to is a native method, but because the java threading model uses the operating system native threading model, where the default Thread nativeway refers to the generation of Native the POSIX Thread Library .
  • There are three implementations of the thread: a kernel thread are implemented (1: 1 implemented), implemented using the user thread (1: N), plus the use of lightweight processes user threads hybrid implementations (N: M implemented). The Java 1.3 from the start threading model widely used operating system native threading model to achieve, namely 1: 1.
  • Hotpot he is not going to interfere with thread scheduling, thread priorities can be set to provide OS scheduling recommendations.
  • Linux system and the different PID each process or LWP is associated. On the other hand, all threads of a multithreaded application in only one and the same PID.
  • Because multiple threads have the same PID, it introduces the concept of a thread group , while the same process leading to all threads of a thread group and the thread group of PID, which is the group first lightweight process the PID, it is stored in the process described in the symbol field tgid.
  • There are threads on real meaning, its implementation is to simulate the process, it belongs to the user-level threads, located libpthread shared library. Specific data structure in memory, it is a process descriptor pointer points to the thread_info data structure, this is the thread descriptor, the size of the storage area for the two leaf frame (2 * 4K).

Q&A

  • Q1: fork in a program, different location code created (), so this program is multi-threaded?
  • A: multi-process communication relations program wrong, fork create the same program () to create a program, belonging to the parent and child between each fork () (parent and child can be allowed only way his son-process communication pipe , and FIFO is allowed to communicate with non Sons).
  • Q2: How many operating system creates a process up to, how many threads to create up to a process?
  • A: the operating system processes a line created by the most proc table (under Linux /proc) related to the size, and procthe size of the table depends on the width of the bus (as bus width determines the number of pointers), such as a 4G.
  • Q3: How do I view kernel threads?
  • A:ps afx

Reference Bowen:

Multi-threaded programming Summary: https://blog.csdn.net/skyroben/article/details/72793409
"in-depth understanding of the Java Virtual Machine: JVM advanced features and best practices" for
"in-depth understanding of linux kernel"

Guess you like

Origin www.cnblogs.com/SsoZhNO-1/p/12543656.html