Am I correct in my assumption about synchronized block?
        Posted  
        
            by kunjaan
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by kunjaan
        
        
        
        Published on 2010-05-03T03:27:29Z
        Indexed on 
            2010/05/03
            3:38 UTC
        
        
        Read the original article
        Hit count: 400
        
I have a method shout() with a synchronized block.
  private void shout(){
    System.out.println("SHOUT " + Thread.currentThread().getName());
    synchronized(this){
      System.out.println("Synchronized Shout"  + Thread.currentThread().getName());
      try {
        Thread.sleep(50);
      }
      catch (InterruptedException e) {
        e.printStackTrace();
      }
      System.out.println("Synchronized Shout"  + Thread.currentThread().getName());
     }
  }
If I have two Threads that run this method, am I correct in assuming that the two "Synchronized Shout" will always appear one after the other? There can be no other statements in between the "Synchronized Shout"?
© Stack Overflow or respective owner