Java thread pool notes, java Thread Pool

Source: Internet
Author: User

Java thread pool notes, java Thread Pool

A java thread pool is a technology used to create threads in advance. A thread pool creates a number of threads before the threads arrive, stores them in idle queues, and reuse these resources, reduce frequent object creation and destruction,

1. jdk1.5 and above provide a ready-made Thread Pool

2. The top-level interface of the java thread pool is Executor, which is an execution thread tool.

3. The thread pool interface is ExecutorService.


How to implement a thread pool in java

The simplest method is to use java. util. concurrent. Executors.
Call Executors. newCachedThreadPool () to obtain the buffer Thread Pool
Executors. newFixedThreadPool (int nThreads) to obtain a fixed thread pool

For java thread pools

The thread pool only manages threads and does not need to be run. In other words, threads start and run in the 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.