Java thread Pool

Source: Internet
Author: User

The benefits of a thread pool

1. Reduce the consumption of resources. Reduce the consumption caused by thread creation and destruction by reusing the threads that have been created.

2, improve the response speed. When a task arrives, the task can be executed immediately without waiting for the thread to be created.

3, improve the manageability of threads.

Threads in a thread pool are called worker threads

Iii. Several common Java thread pools

1. Fixedthreadpool is a typical and excellent thread pool that has the advantage of thread pooling to increase program efficiency and save the overhead of creating threads. When an online pool is idle, that is, there is no running task in the thread pool, it does not release the worker thread and consumes some system resources.

2. The Cachedthreadpool feature is that when an online pool is idle, that is, when there is no running task in the thread pool, it frees the worker thread and frees up the resources that the worker thread occupies. However, when a new task occurs, it is also necessary to create a fresh worker thread with a certain amount of overhead. Also, when using Cachedthreadpool, be sure to pay attention to the number of control tasks, otherwise, because a large number of threads running at the same time, it will cause system paralysis.

3,newschedulethreadexecutor size unlimited thread pool, support timed and periodic execution threads

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.