class stopThreadDemo
{
public static void main(String[] args)
{
StopThread st=new StopThread();
Thread t1=new Thread(st);
Thread t2=new Thread(st);
t1.start();
t2.start();
int num=0;
while(true)
{
if (num++==60)
{
t1.interrupt();
t2.interrupt();
break;
}
System.out.println(Thread.currentThread().getName()+".....main");
}
System.out.println("Over!");
}
}
不太会interrupt()的用法,stop()方法已过时,线程停止还有什么方法呢? |
|