package com.shrimpking.t1;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/21 20:12
*/
class ThreadTest implements Runnable{
@Override
public void run()
{
for (int i = 0; true;i++){
System.out.println(i + " " + Thread.currentThread().getName() + " is running");
}
}
}
//ch15-12 守护线程
public class ThreadDaemon
{
public static void main(String[] args)
{
ThreadTest test = new ThreadTest();
Thread th = new Thread(test);
th.setDaemon(true); //守护线程
th.start();
try
{
Thread.sleep(10);
}catch (InterruptedException e){
e.printStackTrace();
}
}
}