While loop bug? Stuck on empty

That’s close enough! You could have a read of Java memory model - Wikipedia for a bit more on caching / as-if-serial / reordering.