jQuery in Action, 3rd edition
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
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Lock()-clarification needed" Watch "Lock()-clarification needed" New topic

Lock()-clarification needed

Palraj Jayaraj
Ranch Hand

Joined: Jun 06, 2012
Posts: 36

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

Joined: Jul 19, 2004
Posts: 8359

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
Palraj Jayaraj
Ranch Hand

Joined: Jun 06, 2012
Posts: 36

Thanks for the fast reply.
I'll go through it and will let you know my feedback
I agree. Here's the link: http://aspose.com/file-tools
subject: Lock()-clarification needed
It's not a secret anymore!