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);
    }
}
}

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

posted @ 2017-09-08 11:27  流氓剑客  阅读(140)  评论(0编辑  收藏  举报