ITeye博客

线程池压测

e_e · 2017-03-22 10:15 · java · thread · 编程语言 · Markdown

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);

    }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。