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

ThreadPoolExecutor入门拾掇

2013-08-23 
ThreadPoolExecutor入门整理ThreadPoolExecutor boss new ThreadPoolExecutor(1, 20, 0L, TimeUnit.MILL

ThreadPoolExecutor入门整理
ThreadPoolExecutor boss = new ThreadPoolExecutor(1, 20, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(100000)); // test1 // ThreadPoolExecutor boss = new ThreadPoolExecutor(1, 20, 0L, TimeUnit.MILLISECONDS, new // ArrayBlockingQueue(100)); // test2 for (int i = 0; i < 10000; ++i) { System.out.println(i); try { boss.submit(new Runnable() { @Override public void run() { while (true) { try { Thread.currentThread().sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }); } catch (Exception e) { System.out.println("error: " + i); } } System.out.println("================"); System.out.println(boss.getActiveCount() + "," + boss.getTaskCount()); System.out.println(boss.getPoolSize() + "," + boss.getCorePoolSize() + "," + boss.getMaximumPoolSize()); System.out.println(boss.getQueue().size()); System.in.read();

?

================
1,10000
1,1,20
9999

热点排行