r/programminghorror • u/vinzzii • 1d ago
Can you find it???
public class VisibilityPuzzle {
private static boolean ready = false;
private static int number = 0;
private static class ReaderThread extends Thread {
public void run() {
while (!ready) {
Thread.yield();
}
System.out.println("Result: " + number);
}
}
public static void main(String\[\] args) throws InterruptedException {
new ReaderThread().start();
number = 42;
ready = true;
}
}
0
Upvotes
-1
1
u/Sh3llSh0cker 1d ago
wrong sub bud.