use of com.emily.cloud.test.api.po.User in project spring-parent by mingyang66.
the class PoolMain method main.
public static void main(String[] args) throws Exception {
ObjectFactory orderFactory = new ObjectFactory();
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(5000);
// 设置获取连接超时时间
config.setMaxWaitMillis(1000);
GenericObjectPool<User> connectionPool = new GenericObjectPool<User>(orderFactory, config);
long start = System.currentTimeMillis();
for (int i = 0; i < 100000; i++) {
User o = connectionPool.borrowObject();
// User o = new User();
// System.out.println("brrow a connection: " + o +" active connection:"+connectionPool.getNumActive());
connectionPool.returnObject(o);
}
System.out.println(System.currentTimeMillis() - start);
}
Aggregations