专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 移动开发

线程池中全部线程结束捕捉

发布时间:2010-05-30 05:29:01 文章来源:www.iduyao.cn 采编人员:星星草
线程池中所有线程结束捕捉

  下面的代码只是一个引子或者一种方案。    

  ThreadPoolExecutor threadPool=new ThreadPoolExecutor(20, 50, 50000,TimeUnit.MILLISECONDS
            , new ArrayBlockingQueue<Runnable>(5, true));
        for(int i=0;i<30;i++)
        {
            threadPool.execute(new Runnable()
            {
                public void run()
                {
                    try
                    {
                        int random=getRandom(500, 4000);
                        Thread.sleep(random);
                        ++count;
                        if(count>=30)
                        {
                          System.out.println("All Thread is Finished!!!!!!!!!!!!!!"); 
                        }
                    }catch (InterruptedException e){}
                }
            });
        }

友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: