67,549
社区成员




public class Interrupt {
public static void main(String[] args) {
Runnable it=new InterruptTest();
Thread thread=new Thread(it);
thread.start();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
thread.interrupt();
}
}
class InterruptTest implements Runnable {
@Override
public void run() {
int i=0;
while(true){
System.out.println(i++);
}
}
}