1
public static void main(String[] args) throws Exception {
new Thread(new Runnable() {
public void run() {
while(true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Hello");
}
}
}).run();
System.out.println("Bye");
}
在主要的thead中,我创建了一个新的线程,它会每秒打印一个“hello”。为什么最后的“再见”从未得到过印刷品?换句话说,为什么子线程阻塞主线程?java中的子线程块父线程
[Java中运行多线程的问题]的可能重复(http://stackoverflow.com/questions/4235487/problem-running-multiple-threads-in-java) – Gray