Why do we need volatile on primitives? The most common example that I found was that:
volatile boolean shutdownRequested;
...
public void shutdown() { shutdownRequested = true; }
public void doWork() {
while (!shutdownRequested) {
// do stuff
}
}
But when I been trying to run it by myself. Volatile declaration changed nothing. It stops with both volatile and not volatile shutdownRequested