Introduction to the status of threads in the Java thread pool

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.