Running the code:
Thread tt = new Thread(new Runnable() {
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
}
});
System.out.println(tt.getName());
tt.run();
I would expect to get:
Thread-0
Thread-0
But instead I get:
Thread-0
main
Why is that?