title: Should you synchronize the run method? Why or why not?
body: <p>I have always thought that synchronizing the run method in a java class which implements Runnable is redundant. <strong>I am trying to figure out why people do this:</strong></p>
  
  <pre><code>public class ThreadedClass implements Runnable{
      //other stuff
      public synchronized void run(){
          while(true)
               //do some stuff in a thread
          }
      }
  }
  </code></pre>
  
  <p>It seems redundant and unnecessary since they are obtaining the object's lock for another thread. Or rather, they are making explicit that only one thread has access to the run() method. But since its the run method, isn't it itself its own thread? Therefore, only it can access itself and it doesn't need a separate locking mechanism?</p>
  
  <p>I found a suggestion online that by synchronizing the run method you could potentially create a de-facto thread queue for instance by doing this:</p>
  
  <pre><code> public void createThreadQueue(){
      ThreadedClass a = new ThreadedClass();
      new Thread(a, "First one").start();
      new Thread(a, "Second one, waiting on the first one").start();
      new Thread(a, "Third one, waiting on the other two...").start();
   }
  </code></pre>
  
  <p>I would never do that personally, but it lends to the question of why anyone would synchronize the run method. <strong><em>Any ideas why or why not one should synchronize the run method?</em></strong></p>