title: Synchronized method execute with non-synchronized method at the same time
body: <p>Here is the code</p>
  
  <pre><code>public class Test {
  
    public static void main(String[] args) {
  
      PrintLoop pl = new PrintLoop();
  
      Thread a = new Thread(() -&gt; {
        String threadName = Thread.currentThread().getName();
        pl.print(threadName, 5);
        pl.printTenTiems(threadName);
      }, "A");
  
      Thread b = new Thread(() -&gt; {
        String threadName = Thread.currentThread().getName();
        pl.print(threadName, 5);
      }, "B");
  
      a.start();
      b.start();
    }
  
  }
  
  class PrintLoop{
    public synchronized void print(String threadName, int times){
      System.out.println(threadName + ":print start");
      for(int i = 0; i &lt; times; i++){
        System.out.println(threadName + ":" + i);
      }
      System.out.println(threadName + ":print end");
    }
  
    public void printTenTiems(String threadName){
      System.out.println(threadName + ":printTenTiems start");
      for(int i = 0; i &lt; 10; i++){
        System.out.println(threadName + ":" + i);
      }
      System.out.println(threadName + ":printTenTiems end");
    }
  
  }
  </code></pre>
  
  <p>Can anyone explain why the <code>pl.print()</code> invoked in thread B isn't locked and is executing with <code>pl.printTenTimes()</code> simultaneously? As I know the synchronized method will lock the whole object when invoked in a thread. </p>