1.下面的程序定义了一个线程类,请填空把程序补充完整。 public class MyThread implements (1) { private int num = 0; private boolean stop = false; public static void main(String[] args
时间: 2024-04-26 19:23:54 浏览: 90
这是一个线程类(Thread
) {
MyThread thread = new MyThread();
thread.start();
}
public void run() {
while(!stop) {
num++;
System.out.println("Current number is: " + num);
try {
Thread.sleep(1000);
} catch(InterruptedException e) {
e.printStackTrace();
}
}
}
public void stopRunning() {
stop = true;
}
}
Runnable
阅读全文