Gavin Rasa 3.x源码高手之路 系统架构、内核算法、源码实现讲解
import java.util.concurrent.CountDownLatch;public class Main {
public static void main(String[] args) throws InterruptedException {
CountDownLatch latch = new CountDownLatch(10);
for (int i = 0; i < 10; i++) {
int finalI = i;
new Thread(() -> {
int second = new Random().nextInt(10);
try {
Thread.sleep(second * 10