Ankit Garg wrote:If you synchronize a method, then only that method is synchronized. Any other non-synchronized method that this method calls can be called by any other thread on the same object at the same time...
Ankit, Very good use of word.
ragi, please note that "any other thread on the same object" means the following:
Here t1 and t2 are two different threads on the same object dc.
if you use synchronized block then scope of synchronization remains on block boundary e.g.
though points to remember
1) Java supports re entrant entry , so if a thread calls another synchronized method (which synchronize on same object whose lock calling thread holds) it will go there without waiting because it holds the lock.
2) Thread acquire lock before entering synchronized block/method and releases lock when they leave block (either normal or due to exception).