wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes THREAD LOCKS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "THREAD LOCKS" Watch "THREAD LOCKS" New topic
Author

THREAD LOCKS

sunilkumar ssuparasmul
Ranch Hand

Joined: Dec 13, 2000
Posts: 142
can somebody please explain what the following sentence means

"Locks on inner/outer objects are independent. Getting a lock on outer object doesn�t mean getting the lock on an inner object as well, that lock should be obtained separately."
Thanks in advance
sunil.s


"Winners don't do different things<br /> They do things differently"
Bharatesh H Kakamari
Ranch Hand

Joined: Nov 09, 2000
Posts: 198
Locks on inner/outer objects are independent.
Every class has a lock. This means that with respect to Inner classes, the outer class has a lock and the inner class also has a lock independent of the outer class.

Getting a lock on outer object doesn�t mean getting the lock on an inner object as well, that lock should be obtained separately
As the Outer and Inner class lock are independent of each other you have to obtain a lock for an Inner class Object if you have to access the sychronized methods of the Inner class. Acquring a lock on the Outer class Object is not sufficient to execute synchronized methods of the Inner class.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: THREAD LOCKS
 
Similar Threads
Threads and Inner Classes
synchronization confusion
Lock on Inner class object
Inner Class
Lock question!