码迷,mamicode.com
首页 > 编程语言 > 详细

java多线程

时间:2017-08-05 12:39:45      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:service   exception   sleep   bind   使用   rup   cti   log   use   

@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]);
    }

 

java多线程

标签:service   exception   sleep   bind   使用   rup   cti   log   use   

原文地址:http://www.cnblogs.com/zfzf1/p/7289792.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!