following is paragraph from kb 6 book page no. 735.
With locks. Every object in Java has a built-in lock
that only comes into play when the object has synchronized method code. When
we enter a synchronized non-static method, we automatically acquire the lock
associated with the current instance of the class whose code we're executing (the
this instance).
does this means that if an object does not have synchronized methods, we can't acquire lock on that object. if we can acquire the lock , then how we do that ?
according to me the answer is yes, we can acquire lock on any object in
java whether it has synchronized methods or not. we can do so using synchronized blocks. please somebody confirm if this is right ???