Runnable 接口 如果调用线程?
以下程序运行报错 ,MyRun 的sleep 如何指定是那个 Thread 的。
import java.util.*;public class Testinterrupt{ public static void main(String [] args) { MyRun r = new MyRun(); Thread t = new Thread(r); t.start(); try { t.sleep(10000); } catch(InterruptedException e) { } t.interrupt(); }}class MyRun implements Runnable{ public void run() { while(true) { System.out.println("====="+new Date()+"========"); try { sleep(1000); } catch(InterruptedException e) { return; } } }}