咱們先來看看一個網友寫的 SafeObjectPool :html
http://www.javashuo.com/article/p-wwlawmup-bp.htmlspa
從 SafeObjectPool , 咱們大概能夠本身實現一個 線程池, 好比線程
var pool = new SafeObjectPool.ObjectPool<Thread>();htm
Thread thread = pool.Get();blog
thread.喚醒();隊列
喚醒後, thread 會進入 就緒隊列, 很快就能夠執行了 。get
這樣算能夠實現一個 線程池 了吧 ?thread