package com.shi.juc.thread;
/**
* @author shiye
* @create 2022-07-08 11:46
*/
public class MyThread1 {
public static void main(String[] args) throws InterruptedException {
Thread t1 = new Thread(()->{
System.out.println(Thread.currentThread().getName() + "\t 开始运行, " + (Thread.currentThread().isDaemon() ? "守护线程":"用户线程"));
while (true){
}
},"t1");
//t1.setDaemon(true); //t1 开始运行, 守护线程
//默认是: t1 开始运行, 用户线程
t1.start();
//展厅几秒
Thread.sleep(3000);
//main 主线程是:用户线程
System.out.println(Thread.currentThread().getName() + "\t 主线程是:" + (Thread.currentThread().isDaemon() ? "守护线程":"用户线程"));
}
}