package thread0411;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Random;
import java.util.concurrent.TimeUnit;
/**
* 1. 依次启动十个线程放在一个线程组里, 每个线程随机完成若干时间的任务
* 23. 查看线程组状态
* 4. while检测是否十个线程都还在active状态, 如果是则阻塞.
* 5. 终止线程组中的所有线程.
*/
public class ThreadGroupDemo {
public static void main(String[] args) {
// 创建线程组
ThreadGroup threadGroup = new ThreadGroup("Searcher111");
// 创建一个任务, 10个线程完成
System.out.println(LocalDateTime.now() + " => " + "====== 1 子线程启动 ======");
Result result = new Result();
Searcher searchTask = new Searcher(result);
for (int i = 0; i < 10; i++) {
Thread thread = new Thread(threadGroup, searchTas