-1
运行代码:意外的线程执行
Thread tt = new Thread(new Runnable() {
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
}
});
System.out.println(tt.getName());
tt.run();
我希望得到:
Thread-0
Thread-0
而是我得到:
Thread-0
main
这是为什么?
在线程上调用'start()',而不是'run()'。 –
是的,对不起,因为愚蠢:-( – Johnny