title: Synchronization based on an object declared as "final static Object" vs. simply "final Object"
body: <p>I have a question regarding Java concurrency. If I synchronize a critical section based on an object, what is difference between declaring that variable as a <code>final static Object</code> versus simply <code>final Object</code>.</p>
  
  <p>I understand that the <code>static</code> keyword defines a variable as belonging to the class, but I'm a little hazy on its meaning in a multi-threaded environment.</p>
  
  <p>Please refer to the code sample below. Currently I have the <code>lock</code> object declared as <code>private final Object lock = new Object()</code>, what will be the difference if I add the <code>static</code> keyword?</p>
  
  <pre><code>class ConcurrencySample {
      private String message = null;
      private final Object lock = new Object();
      //private final static Object lock = new Object();
  
      public void setMessage(String msg) {
          synchronized (lock) {
              message = msg;
          }
      }
      public String getMessage() {
          synchronized (lock) {
              String temp = message;
              message = null;
              return temp;
          }
      } 
  }
  </code></pre>
  
  <p>Thanks for the help!</p>