Hi,
I have a small doubt in
Thread. Whether lock is for methods or objects.
For example:
I am having a object 'a' which has three methods 'method1()' and 'method2()' and method3().
Of which, mehtod1() and method2() are synchronized.
Object a:
---------
synchronized method1(){}
synchronized method2(){}
method3(){}
Whether a thread by name 't1' now acquiring lock on Object a or method1()?
If a thread 't1' is holding the lock of method1(), is it possible for some other thread 't2' to acquire lock on method2() of same object 'a'.
Please clarify my doubts and also give your tips regd this.
Note: Based upon the answer from the group, I have one more question to ask.