my minecraft mod only works when i add System.out.println. is my code haunted 💀
ok so this is lowkey the weirdest bug ive ever had. im making a mod with a background thread that loads some stuff and the main thread waits for it to finish. works fine in my dev env but on my mates pc it just freezes forever. no crash no error nothing
heres the important bits
public class Loader {
private boolean done = false;
public void start() {
new Thread(() -> {
loadAllTheThings();
done = true;
}).start();
}
public void waitForIt() {
while (!done) {
// waiting
}
System.out.println("loaded!");
}
}
the cursed part: if i put System.out.println("waiting"); inside the while loop it works EVERY time on every pc. take it out, freezes. bro how does printing something fix it. is java haunted fr. no cap ive been on this for 2 days and yr 11 exams are next week 💀
Accepted answer
Get the best of Dynamo Geeks weekly
One email each Monday with the most useful posts. No spam; unsubscribe in one click.
Comments
Sign in to join the conversation.
Sign in to commentAccepted answer