public class n {
public static void main(String[]args) throws InterruptedException
{
test t=new test();
test2 t2=new test2();
new Thread(t).start();
Thread tt2=new Thread(t2);
tt2.setDaemon(true);//在t用户线程结束后结束
tt2.start();
}
}
class test implements Runnable
{
public void run()
{
for(int i=1;i<=365*100;i++)
{
System.out.println("me");
}
System.out.println("he");
}
}
class test2 implements Runnable{
public void run()
{
for(;true;)
{
System.out.println("she");
}
}
}
原文:https://blog.51cto.com/14437184/2428993