class myRunnable implements Runnable {
public void run() {
// TODO Auto-generated method stub
System.out.println("run");
}
}
public class TestThread {
public static void main(String[] args) {
Runnable threadJob = new myRunnable();
Thread t = new Thread(threadJob);
t.start();
for (int i = 0; i < 100000; i++) {
System.out.println("main");
}
}
}
重新显示在控制台中:
主要
主要
主要
主要
...
主要
主要
主要
主要
我找不到任何“运行”字,这意味着run方法未运行。有人可以帮我解释一下。谢谢。
PS:当i
最佳答案
Run
已被打印出来。但是您的控制台缓冲区不是很大。
将控制台配置更改为无限缓冲区。
关于java - 线程不起作用?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28149799/