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.