java守护线程

package com.ada.wuliu.shipper.front.service.thread;

public class TestDeamon {
public static class DeamonT extends Thread{
    public void run(){
        while(true){
            System.out.println("=========");
            try {
                Thread .sleep(1000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    public static void main(String[] args) throws InterruptedException {
        //守护当前线程 如果当前线程执行完成之后 守护线程也停止
        DeamonT t=new DeamonT();
        t.setDaemon(true);
        t.start();
        Thread .sleep(5000);
    }
}
}

 =========
=========
=========
=========
=========

原文地址:https://www.cnblogs.com/lmjk/p/7493715.html