线程池压测
程序员文章站
2022-03-26 12:13:17
...
public static void main(String[] args) throws Exception {
ExecutorService es = Executors.newFixedThreadPool(300);
Callable<Object> cb = new Callable() {
@Override
public Object call() throws Exception {
Connection conn = Neo4jUtil.getConnection();
Statement statement = conn.createStatement();
TimeUnit.SECONDS.sleep(1);
Neo4jUtil.freeConnection(null, statement, conn);
return null;
}
};
List<Callable<Object>> cl = new ArrayList<>();
for(int j=0;j<=400;j++){
cl.add(cb);
j++;
}
es.invokeAll(cl);
}
下一篇: 日期类型 GMT与UTC转换