jvm - does java -server flag make any sense? -


I think everyone knows - whether it's running on server command line JVM parameter Java running the server as a server Also means kind of ??

I've read that it does some more optimization, and because of this, some of your Java code can behave differently

  boolean flag = true; While (flag) {if (checkMethod ()) {flag = false; }}  

[edit] This code will work fine in both scenarios 1. Without-server and 2.with-server , Please update once again with the correct test code.

It will never come from the time of the loop ..

We have just launched a new project, should we use the server to test? Are you using it?

& amp; I wonder if it really makes sense and it is really important, why do not use server documents / official documents such as Tomcat / JetT / Geronimo etc / code / show-server tags in any code examples ??? ?

Cheers

Yes, when you use the server flag Java can behave differently, but for this program requires at least one error. The only case that I can think of is a missing volatile or missing synchronization, for variables being used by multiple threads is.

  Expands class runner thread {Boolean stop = false; Public run zero () (while (stop!) {DoSomething ();}} Public exit from zero () {stop = true;}}  

Exiting without optimization () method call The thread will help to exit the loop, when optimization can be turned on the adapter, it can be looping that the loop will never end and will not be replaced with a simple jump, because the stop is not volatile Is not and can not be modified from within the loop This behavior should be expected.

This behavior should be expected because the variables used by multiple threads should be declared vaporized or transmitted only on synchronized methods. Just remember that one in thread The stop () method is, it has been clearly changed to exit.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -