Java thread pool

Source: Internet
Author: User

Java.util.concurrent Bag

interface and related class inheritance relationship:

Executor

|-executorservice <-Threadpoolexecutor

|-scheduledexecutorservice <-Scheduledthreadpoolexecutor

Because the Threadpoolexecutor and scheduledthreadpoolexecutor constructors are too complex, they are set by default using the class executors

There are five factory methods inside the executors that generate the thread pool (the default settings for Threadpoolexecutor and Scheduledthreadpoolexecutor parameters are set internally by the method):

1. Newcachedthreadpool ()

No boundary pool: Creates a new thread when there is a task, and the idle thread retains 60s auto-recycle

2. Newfixedthreadpool ()

Fixed size thread pool: Idle hold, wait if task exceeds thread pool size

3. Newsinglethreadexecutor ()

There is only one worker thread, which executes the task sequentially

4. Newscheduledthreadpool ()

A single worker thread that schedules tasks on a time basis

5. Newsinglescheduledexecutor ()

thread pool for tasks by time schedule (timing, cycle Task)

Java thread pool

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.