title: Synchronized block will lock the whole object or the method alone?
body: <p>I have multiple methods in a class and most of the methods are having critical sections(shared data). So I made those methods as synchronized. Say thread t1 is running one of the synchronized block . At the same time thread t2 can access the other methods critical section ? </p>
  
  <pre><code>class Sample{
  
  synchronized public void method1(){
  
  }
  
  synchronized public void method2(){
  
  }
  
  synchronized public void method3(){
  
  }
  
  public void method4(){
  
  }
  
  }
  </code></pre>