From Goetz - Java Concurrency in Practice:
- Debugging tip: For server applications, be sure to always specify the
-server
JVM command line switch when invoking the JVM, even for development and testing. The server JVM performs more optimization than the client JVM, such as hoisting variables out of a loop that are not modified in the loop; code that might appear to work in the development environment (client JVM) can break in the deployment environment (server JVM). For example, had we “forgotten” to declare the variable asleep as volatile in Listing 3.4, the server JVM could hoist the test out of the loop (turning it into an infinite loop), but the client JVM would not. An infinite loop that shows up in development is far less costly than one that only shows up in production.Listing 3.4. Counting sheep.
volatile boolean asleep; ... while (!asleep) countSomeSheep();
My emphasis. YMMV