Can someone explain to me why the following code prints nothing?
When I tried to debug it, the debugger froze on the line t.join();
. But in the debugger I saw the message: "program is running".
public class Main_problem1_multithreading {
private static boolean initialized = false;
static {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
initialized = true;
}
});
t.start();
try {
t.join();
} catch (InterruptedException e) {
throw new AssertionError(e);
}
}
public static void main(String[] args) {
System.out.println(initialized);
}
}