线程分两种:
守护线程(Daemon)
用户线程

守护线程Thread.setDaemon(true)设置
一般程序使用用户线程,特殊的如垃圾回收线程使用守护线程

守护线程为用户线程服务的,用户线程关闭了,守护线程也会关闭。
守护线程定义要在Thread.start()之前
优先级一般较低

@Test
public void testT() {
System.out.println("testT start");
Thread thread = new MyThread();
thread.setName("守护线程");
thread.setDaemon(true);
thread.start();
System.out.println("testT end");

}

class MyThread extends Thread {
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
System.out.println(Thread.currentThread().getId());
System.out.println("start");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
log.error("e:", e);
}
System.out.println("end");
}

}