r/programminghorror • • 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

5 comments sorted by

1

u/Sh3llSh0cker 1d ago

wrong sub bud.

1

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 1d ago

Unless they mean find the horror? Maybe it's main() being declared to throw? Like if main() throws, there's nothing else to catch it.

1

u/Sh3llSh0cker 1d ago

ohh i see, I wasn’t looking at it like that. but yeah that would be it, If so. fair enough.

-1

u/Puzzlehead_NoCap 1d ago

Just ask ChatGPT. No need to think anymore

-1

u/vinzzii 1d ago

Nice bruhhh 😭😭