Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 557305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:00:45+00:00 2026-05-13T12:00:45+00:00

I think everyone is aware of -server command line JVM parameter. Does it make

  • 0

I think everyone is aware of -server command line JVM parameter. Does it make any sense while running Java application as Server??

I read that it does some more optimizations, and because of that, some of your Java code can behave differently like

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

[EDIT] this code will work fine(same) in both scenario 1. without -server and 2. with -server, Will update once again with proper testable code.

it will never come out of while loop..

We have just started a new project, should we start using -server for testing?
Are you using it?

& I wonder if it really make sense and it is really important, why official document/tutorials of server products like tomcat/jetty/geronimo etc. never use/show -server tag in code examples ????

Cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:00:45+00:00Added an answer on May 13, 2026 at 12:00 pm

    yes java can behave different when you use the -server flag, but that requires the program itself to have at least one error. The only case I can think of is a missing volatile or missing synchronisation for a variable accessed by multiple Threads.

    class Runner extends Thread
    {
    boolean stop = false;
    public void run()
    {
       while (!stop)
       {
           doSomething();
       }
    }
    public void exit()
    {
        stop = true;
    }
    }
    

    Calling the exit() method without optimization will lead the thread to exit the loop, when optimization is turned on the optimizer may gues that the loop will never end and replace the test with a simple jump, as stop is not volatile and is not modified from within the loop.
    This behavior has to be expected as a variable accessed by several threads should either be declared volatile or accessed only over synchronized methods.
    just remembered that there is a stop() method in Thread, replaced it with exit() for clarity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think everyone here would be knowing that, if I am logged in any
I think everyone knows this site http://pinterest.com/ and I don't want to create site
It has been asked when MeteorJS will have auth in place... I think everyone
I think everyone has experience working with a code like the following: void fun(Type1&);
I am using Java (although I think the socket options is implement in most
I used to think that everyone used relative paths (e.g. /styles/style.css ). But I
I think everyone here would agree that in order to be considered a professional
What are the expert debugging hints for your favourite language, you think everyone should
HI everyone, I'd be interested to know what people think about the concept of
I'm basically wondering if Python has any OOP shortcomings like PHP does. PHP has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.