First, define the various states of the thread in the JVM (in the Javacore file)
1. Deadlock, Deadlock (focus on)
2. Implementation, Runnable (focus on)
3. Waiting for resources, waiting on condition (focus)
4. Wait for the monitor to check the resources, waiting on monitor (eg: if you need to allocate computer resources such as System.out.println and so on, the thread waits, mainly depends on the stack)
5. Pause, Suspended
6. Object waiting, Object.wait ()
7. Blocking, Blocked (focus on)
8. Stop, parked (this state must be clear, different from the literal meaning, mainly refers to the state of the thread's idle time.), such as in a thread pool, when the threads are called and put into the pool again, their state becomes parked)
Implementation of the Java basic thread pool
Public threadpoolexecutor (int corepoolsize, int maximumpoolsize, long keepalivetime, timeunit unit, Blockingqueue<ru Nnable> workQueue)
The parameters are detailed below:
Corepoolsize-the number of threads that are saved in the pool, including idle threads. (Core thread)
Maximumpoolsize-The maximum number of threads allowed in the pool.
KeepAliveTime-This is extra idle before terminating when the number of threads is greater than the core
The maximum time that a thread waits for a new task.
The time unit of the Unit-keepalivetime parameter.
WorkQueue-the queue used to hold the task before execution. This queue remains only by the Execute
the Runnable task that the method submits.
The relationship between the above parameter queue WorkQueue and Corepoolsize, Maximumpoolsize is:
if the thread in Corepoolsize is exhausted, the queue WorkQueue is used and the queue is used up to start a new thread in the size of maximumpoolsize
Use different directives for different operating systems for the generation of Javacore files
Linux and Unix directives used are: jstack-l pid >>core file name
The instructions used by IBM for AIX are: kill-3 PID
In addition, according to the test situation. Parked state threads are not available on Linux and UNIX. Only threads that parked state on AIX can be represented, and it is estimated that this is related to the implementation of different JVMs.
The origin of the parked state: Only used threads are placed in the thread pool again to be given this state
Introduction to the status of threads in the Java thread pool