java多线程

@Test
    public void useMmSectionSLEntityByBindCode2() throws InterruptedException {
        final String bindCode = "CSK000003";
        final int[] count = {0, 0};
        for (int i = 0; i < 1000; i++) {
            final int finalI = i;
            new Thread(new Runnable() {
                @Override
                public void run() {
                    System.out.println("线程" + (finalI + 1) + "开始");
                    Long begin = System.currentTimeMillis();
                    List<String> strings = mmSectionSLService.useMmSectionSLEntityByBindCode(bindCode, 3);
                    if (strings != null) {
                        for (String s : strings) {
                            System.out.println(s);
                        }
                        count[0] += 3;
                    }
                    count[1] += (System.currentTimeMillis() - begin) / 1000;
                }
            }).start();
        }
        Thread.sleep(1000 * 10);
        System.out.println("成功使用号段数: " + count[0]);

        System.out.println("总共耗时: " + count[1]);
    }
原文地址:https://www.cnblogs.com/zfzf1/p/7289792.html