Quantcast
Channel: How would we use try finally for Lock.lock and Lock.unlock - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by Dan R. for How would we use try finally for Lock.lock and Lock.unlock

The other respondents are right: you should always use try/finally.Regarding whether (A) or (B) is correct, Sun seems to recommend (B) in the JavaDoc of ReentrantReadWriteLock (search for "finally" to...

View Article



Answer by Raph Levien for How would we use try finally for Lock.lock and...

It's good defensive programming. If your code ever changes so that the body throws an exception for any reason whatsoever (including, for example, OutOfMemoryError), you'll be glad you didn't leave the...

View Article

How would we use try finally for Lock.lock and Lock.unlock

Consider the following code. In order to prevent IndexOutOfBoundsException while calling listIterator, we use a reader lock to retrieve the index based iteartor, and writer lock else where when write...

View Article
Browsing latest articles
Browse All 3 View Live




Latest Images