Link Details

Link 938411 thumbnail
User 884233 avatar

By screener
Published: Mar 14 2013 / 21:32

Prior to Java 1.5, synchronized and volatile keyword were only way to coordinate access to shared variable, but Java 5 provides another alternative in terms of ReentrantLock. ReentrantLock offers features, which synchronized keyword lacks and which are essential to building non blocking algorithm, such as trying for lock without getting blocked, trying for lock interruptibly and trying lock with timeout. Though ReentrantLock offer same ordering and visibility guarantee, it comes with a danger, programmer need to take care of acquisition and release of lock, which if not difficult but can lead to subtle bugs if programmer forget to release lock in finally block.
  • 7
  • 0
  • 2046
  • 1390

Add your comment

Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (7)

Voters Against This Link (0)

    Apache Hadoop
    Written by: Piotr Krewski
    Featured Refcardz: Top Refcardz:
    1. Play
    2. Akka
    3. Design Patterns
    4. OO JS
    5. Cont. Delivery
    1. Play
    2. Java Performance
    3. Akka
    4. REST
    5. Java