public static void main(String[] args){
System.out.println("main thread start");
List<Thread> list = new ArrayList<Thread>();
for (int i = 0 ; i < 10; i ++){
Thread t = new Thread();
list.add(t);
t.start();
}
for(Thread t : list){
t.join();
}
System.out.println("main thread continue");
}
多个子线程并发执行,主线程等待所有子线程都结束后再继续运行
最新推荐文章于 2022-06-06 15:06:03 发布