org.jboss.messaging.core.util
Class Lockable

java.lang.Object
  extended byorg.jboss.messaging.core.util.Lockable

public class Lockable
extends java.lang.Object

A simple wrapper around a ReentrantLock that provides a locking mechanism to subclasses.

Version:
$Revision: 653 $
Author:
Ovidiu Feodorov

Constructor Summary
Lockable()
           
 
Method Summary
 void lock()
          The thread calling this method acquires a reentrant lock on the current instance.
 boolean lock(long millisecs)
          The thread calling attempts to acquire the reentrant lock for the specified time.
 void unlock()
          The thread calling it gives up the lock on the current instance, if any.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lockable

public Lockable()
Method Detail

lock

public final void lock()
The thread calling this method acquires a reentrant lock on the current instance. The method can wait forever if the lock is being hold by another thread and not released.


lock

public final boolean lock(long millisecs)
The thread calling attempts to acquire the reentrant lock for the specified time.

Returns:
true if succesful.

unlock

public final void unlock()
The thread calling it gives up the lock on the current instance, if any.



Copyright © 2006 JBoss Inc. All Rights Reserved.