org.jgroups.util

Class ReentrantLatch

public final class ReentrantLatch extends Object

Enables safely locking and unlocking a shared resource, without blocking the calling threads. Blocking is only done on the 'passThrough' method.

Version: 1.0

Author: yaronr / Dmitry Gershkovich

Constructor Summary
ReentrantLatch()
Create a new unlocked latch.
ReentrantLatch(boolean locked)
Create a reentrant latch
Method Summary
voidlock()
Lock the latch.
voidpassThrough()
Pass through only when the latch becomes unlocked.
voidunlock()
Unlock the latch.

Constructor Detail

ReentrantLatch

public ReentrantLatch()
Create a new unlocked latch.

ReentrantLatch

public ReentrantLatch(boolean locked)
Create a reentrant latch

Parameters: locked is the latch to be created locked or not

Method Detail

lock

public void lock()
Lock the latch. If it is already locked, this method will have no side effects. This method will not block.

passThrough

public void passThrough()
Pass through only when the latch becomes unlocked. If the latch is locked, wait until someone unlocks it. Does not lock the latch.

Throws: InterruptedException

unlock

public void unlock()
Unlock the latch. If it is already unlocked, this method will have no side effects. This method will not block.
Copyright ? 1998-2005 Bela Ban. All Rights Reserved.