Real differences between “java -server” and “java -client”?

前端 未结 11 2343
旧时难觅i
旧时难觅i 2020-11-22 03:52

Is there any real practical difference between \"java -server\" and \"java -client\"?

All I can find on Sun\'s site is a vague

\"-server st

11条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 04:48

    From Goetz - Java Concurrency in Practice:

    1. 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

提交回复
热议问题