首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

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

2012-07-05 
线程池中所有线程结束捕捉??下面的代码只是一个引子或者一种方案。????? ThreadPoolExecutor threadPoolne

线程池中所有线程结束捕捉

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

? 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){}
??????????????? }
??????????? });
??????? }

热点排行