邢不行量化 A股Python量化课程
for (int i = 0; i < 10; i++) {
int finalI = i;
new Thread(() -> {
int second = new Random().nextInt(10);
try {
Thread.sleep(second * 1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
System.out.println("线程" + finalI + "活干完了");
latch.countDown();
}).start();
}
latch.await();
System.out.println("我是老板,所有工人的活都干完了");
}}