One: Newcachedthreadpool
(1) Cache-type pool, first look at the pool there are no previously established threads, if there is, reuse, if not, set up a new thread to join the pool;
(2) buffer pool, usually used to perform some short-lived asynchronous tasks, so some connection-oriented daemon-type server is not used much;
(3) The thread that can reuse, must be timeout idle in the pool line, the default timeout is 60s, more than this idle time, the thread instance will be terminated and removed from the pool.
(4) Note that the thread that is put into the cachedthreadpool does not have to worry about its end, exceeding timeout inactivity, which is automatically terminated
Two: Newfixedthreadpool
(1) Newfixedthreadpool and Cachethreadpool are similar, but also can reuse use, but can not build new threads at any time
(2) Its uniqueness: At any point in time, there can be at most a fixed number of active threads, at this point, if there are new threads to be established, can only be placed in another queue wait until a thread in the current thread termination is directly removed from the pool
(3) Unlike Cachethreadpool, Fixedthreadpool has no idle mechanism (possibly, but since the document is not mentioned, it must be very long, similar to the TCP or UDP idle mechanism that relies on the upper layer), So Fixedthreadpool most for some very stable and fixed regular concurrent threads, more for the server
(4) from the source code of the method, the cache pool and the fixed pool call the same underlying pool, except that the parameters are different:
Fixed pool thread count, and is 0 seconds idle (no idle)
Cache Pool Threads Support 0-integer.max_value (obviously not considering the host's resource tolerance), 60 seconds idle
Three: Scheduledthreadpool
(1) Scheduling thread pool
(2) The thread in this pool can be executed by schedule, or cycle execution
Four: Singlethreadexecutor
(1) Single thread, only one thread can be in any time pool
(2) using the same underlying pool as the cache pool and the fixed pool, but the number of threads is 1-1, 0 seconds idle (no idle)
Several thread pool comparisons for Java Executorservice