aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Lock()-clarification needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Lock()-clarification needed" Watch "Lock()-clarification needed" New topic
Author

Lock()-clarification needed

Palraj Jayaraj
Ranch Hand

Joined: Jun 06, 2012
Posts: 35

I'm currently preparing for OCJMD..
I've a doubt like



suppose, In the above code, I need to protect the variable 'a' from being accessed by other threads while execution.
I do not understand 'how invoking of lock() method on a 'ReentrantLock' object, will make the current thread to get a lock on the variable 'a'??

Thanks in advance.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5407
    
  13

Have a look at the comments of the lock-method. Because it gives you all you need to know and understand the code.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Palraj Jayaraj
Ranch Hand

Joined: Jun 06, 2012
Posts: 35

Thanks for the fast reply.
I'll go through it and will let you know my feedback
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Lock()-clarification needed