synchronized

 

  synchronized can only appear on a method, or on a code block, or as a statement.

 

  You cannot successfully synchronize on a local variable.  Only objects can have locks. And every thread has its own copy of local variables anyway. 

 

  When synchronized is used on a method, the object reference is this.

 

  Two ways to release synchronized.  Either:

(1) the code exits,or

(2) wait( ) is called.

 

  Overriding subclasses can ignore any synchronized appearing on a method being overridden.