package J20250730;

/**
 * @author WanJl
 * @version 1.0
 * @title Demo06_DaemonThread
 * @description 守护线程
 * @create 2025/7/30
 */
public class Demo06_DaemonThread {
    public static void main(String[] args) {
        Runnable r1=()->{
            for (int i = 0; i < 100; i++) {
                System.out.println(Thread.currentThread().getName()+"->"+i);
            }
        };
        Thread t1=new Thread(r1,"普通线程");
        Thread t2=new Thread(r1,"守护线程");
        //设置守护线程
        t2.setDaemon(true);
        t1.setDaemon(true);
        t1.setPriority(8);
        t2.setPriority(1);
        t1.start();
        t2.start();

    }
}
