8人阅读 评论(0)

//底层还是调用ThreadPoolExecutor，不过参数有变化
//corePoolSize 竟然为0，maximumPoolSize为默认的最大值
//当任务队列满时，就会判断maximumPoolSize大小
//keepAliveTime 空闲线程的最大等待时间，，60s后立马销毁线程了
60L, TimeUnit.SECONDS,
new SynchronousQueue<Runnable>());
}

#### SynchronousQueue

A {@linkplain BlockingQueue blocking queue} in which each insert
* operation must wait for a corresponding remove operation by another
* thread, and vice versa.  A synchronous queue does not have any
* internal capacity, not even a capacity of one. 
• SynchronousQueue，实际上它不是一个真正的队列，因为它不会为队列中元素维护存储空间。与其他队列不同的是，它维护一组线程，这些线程在等待着把元素加入或移出队列。

 Creates a thread pool that creates new threads as needed, but
* will reuse previously constructed threads when they are
* available.  These pools will typically improve the performance
* of programs that execute many short-lived asynchronous tasks.
* Calls to <tt>execute</tt> will reuse previously constructed
* threads if available. If no existing thread is available, a new
* not been used for sixty seconds are terminated and removed from
* the cache. Thus, a pool that remains idle for long enough will
* not consume any resources.