My best guess: add some sleep condition to give the other thread time to populate the result. In your question you say it takes about 5 seconds; this might take (way) longer when you add a busy-wait loop (while true).
try:
while (true) {
while (value == 0) {
value = utils.getValue();
try {
Thread.sleep(500);
}
catch (InterruptedException e) {
}
System.out.println("Value is zero");
}
System.out.println("Value isn't zero, out of loop");
}