suppose i am calling a synchronized method say method1() using a thread say thread1 on an object say obj1 This synchronised method is calling another non synchronised method say method2() on the same object obj1 my question is will another thread say thread2 will be able to call method2() on the same instance obj1 if thread1 is holding a lock on obj1
If you can't be the Sun ..<br /> Be a star ..............
Originally posted by kapil kumar: suppose i am calling a synchronized method say method1() using a thread say thread1 on an object say obj1 This synchronised method is calling another non synchronised method say method2() on the same object obj1 my question is will another thread say thread2 will be able to call method2() on the same instance obj1 if thread1 is holding a lock on obj1
Yes. Since this method is not synchronized the object lock is not required to call this methods. You have method1() and to execute it object1's lock was obtained. To execute method2() the object1 lock is not required since it is not synchronized. If it were then thread 2 will have to wait till thread1 finishes with method1().
If you illustrate the question with a class next time you will perhaps attract more replies. Good luck with your exam