【发布时间】:2013-10-22 21:01:04
【问题描述】:
public Thread thread = new Thread();
public void start() {
running = true;
thread.start();
}
public void run() {
while(running) {
System.out.println("test");
try {
thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
我的问题是程序不会打印出“测试”,也不会看起来循环,尽管“运行”是真的。有没有办法可以在run方法中不断循环?
【问题讨论】:
-
您展示的
run()方法实际上是否属于您启动的实际线程子类?
标签: java