private static void latchTest() throws InterruptedException {
final CountDownLatch start = new CountDownLatch(1);
final CountDownLatch end = new CountDownLatch(300);
ExecutorService exce = Executors.newFixedThreadPool(300);
for (int i = 0; i < 300; i++) {
Runnable run = new Runnable() {
@Override
public void run() {
try {
start.await();
// 测试执行具体的方法
testLoad();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
end.countDown();
}
}
};
exce.submit(run);
}
start.countDown();
end.await();
exce.shutdown();
}