title: Multiple Threads calling static helper method
body: <p>I have a web application running on Tomcat.</p>
  
  <p>There are several calculations that need to be done on multiple places in the web application. Can I make those calculations static helper functions? If the server has enough processor cores, can multiple calls to that static function (resulting from multiple requests to different servlets) run parallel? Or does one request have to wait until the other request finished the call?</p>
  
  <pre><code>public class Helper {
      public static void doSomething(int arg1, int arg2) {
          // do something with the args
          return val;
      }
  }
  </code></pre>
  
  <p>if the calls run parallel:
  I have another helper class with static functions, but this class contains a private static member which is used in the static functions. How can I make sure that the functions are thread-safe?</p>
  
  <pre><code>public class Helper {
  
      private static SomeObject obj;
  
      public static void changeMember() {
          Helper.obj.changeValue();
      }
  
      public static String readMember() {
          Helper.obj.readValue();
      }
  
  }
  </code></pre>
  
  <p><code>changeValue()</code> and <code>readValue()</code> read/change the same member variable of <code>Helper.obj</code>. Do I have to make the whole static functions synchronized, or just the block where <code>Helper.obj</code> is used? If I should use a block, what object should I use to lock it?</p>