If you have a method
public synchronized void methodA()
{
while(condition)
{
// do Something That Takes A Minute ;
}
// do Something That Needs A Lock;
while(condition)
{
// do Something That Takes Another Minute ;
}
}
It will hold lock for 2 minutes more than
public void methodA()
{
while(condition)
{
// do Something That Takes A Minute ;
}
synchronized(this)
{
// do Something That Needs A Lock;
}
while(condition)
{
// do Something That Takes Another Minute ;
}
}
In case of highly concurrent applications, that difference in the time for which the lock is held is very significant.
Arguably you can break the method 2 down into 2 methods and apply synchronized at method level, but that might at times lead to bad code.
SO both facilities are provided by Java.