r/programminghorror • • Nov 04 '26

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

8 comments sorted by

2

u/Sh3llSh0cker Nov 04 '26

wrong sub bud.

1

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Nov 04 '26

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 Nov 04 '26

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

2

u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: 29d ago

Why isn't this in a code block?

-1

u/Puzzlehead_NoCap Nov 04 '26

Just ask ChatGPT. No need to think anymore

0

u/vinzzii Nov 04 '26

Nice bruhhh 😭😭

0

u/[deleted] 26d ago

[removed] — view removed comment

1

u/Puzzlehead_NoCap 26d ago

It’s a foolproof plan. There is absolutely nothing that can go wrong.