public class ObjectPoolDemo {
static PoolableObjectFactory factory = new PoolableObjectFactoryDemo()
static ObjectPool pool = new GenericObjectPool(factory)
private static AtomicInteger endcount = new AtomicInteger(
public static class PoolThread extends Thread{
public void run(){
Object obj = null;
try {
for (int i =
System
obj = pool
System
pool
}
} catch (Exception e) {
e
} finally {
endcount
}
}
}
public static void main(String[] args) {
new PoolThread()
new PoolThread()
new PoolThread()
try{
while(true){
if(endcount
pool
break;
}
}
}catch(Exception e){
}
}
}
返回目錄
編輯推薦
Java程序設計培訓視頻教程
J
J
Visual C++音頻/視頻技術開發與實戰
Oracle索引技術
ORACLE
[
From:http://tw.wingwit.com/Article/program/Java/gj/201311/27796.html