Android (Java) Learning Note 267:android thread pool

Source: Internet
Author: User

1. Thread pool

(1) advantages of thread pool:

    • reuse threads in the thread pool to avoid the performance overhead associated with creating and destroying threads.
    • It can effectively control the maximum concurrency of the thread pool, and avoids the blocking phenomenon caused by the large number of threads that preempt the system resources.
    • enables simple management of threads and provides functions such as timed execution and specified interval loop execution.

(2) thread pool in Android:

The concept of a thread pool in Android comes from Executor,executor in Java as an excuse, and the real thread pool is implemented as Threadpoolexecutor.

Threadpoolexecutor provides a set of parameters to configure the thread pool, with different parameters to create different thread pools .

From the functional characteristics of the thread pool, the Android thread pool is divided into 4 classes , which can be obtained by the factory method provided by executor. 4 Class thread pools.

Since the thread pool in Android is implemented directly or indirectly by configuring Threadpoolexecutor , we'll introduce threadpoolexecutor here.

2. Threadpoolexecutor

Threadpoolexecutor is the real implementation of the thread pool, and its construction method provides a set of parameters to configure the thread pool.

The following describes the meaning of each parameter in Threadpoolexecutor's constructor, which will directly affect the function of the thread pool, and a more common construction method below Threadpoolexecutor:

Android (Java) Learning Note 267:android 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.