邢不行量化 A股Python量化課程
2022-11-12 20:35 作者:三國(guó)盡歸許佳琪 | 我要投稿
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("我是老板,所有工人的活都干完了");
?}}
標(biāo)簽: