Thread pool Work queue saturation policy

Source: Internet
Author: User

Thread pool Work queue saturation policy

The Java thread pool places the submitted task first in the work queue, which is fetched from the work queue (Synchronousqueue is submitted directly by the producer to the worker thread).

Then there are two implementation strategies for the work queue: unbounded queues and bounded queues.

There is no saturation problem with unbounded queues, but the problem is that when the request continues to load heavily, the task will not join the work queue without a brain, so it is likely to cause resources such as memory to overflow or drain.

While bounded queues do not cause memory exhaustion due to high load, there is a challenge of how the new submitted task will be managed when the work queue is full, which is the problem that the thread pool work queue saturation policy solves.

There is no saturation problem with unbounded queues, but the problem is that when the request continues to load heavily, the task will not join the work queue without a brain, so it is likely to cause resources such as memory to overflow or drain.

While bounded queues do not cause memory exhaustion due to high load, there is a challenge of how the new submitted task will be managed when the work queue is full, which is the problem that the thread pool work queue saturation policy solves.

The saturation strategy is divided into: Abort policy, callerruns policy, discard policy, discardolds strategy.

When the work queue is full, the different policies are handled in the following ways:

1.Abort policy: The default policy, when a new task commits, throws an unchecked exception rejectedexecutionexception, which can be captured by the caller.

When the work queue is full, the different policies are handled in the following ways:

1.Abort policy: The default policy, when a new task commits, throws an unchecked exception rejectedexecutionexception, which can be captured by the caller.

The program throws a Rejectedexecutionexception

The program throws a Rejectedexecutionexception

Thread pool Work queue saturation policy

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.