org.jboss.ejb.plugins.lock
Class NonReentrantLock

java.lang.Object
  extended by org.jboss.ejb.plugins.lock.NonReentrantLock
All Implemented Interfaces:
org.jboss.util.deadlock.Resource

public class NonReentrantLock
extends Object
implements org.jboss.util.deadlock.Resource

Implementents a non reentrant lock with deadlock detection

It will throw a ReentranceException if the same thread tries to acquire twice or the same transaction tries to acquire twice

Version:
$Revision: 57209 $
Author:
Bill Burke, Alexey Loubyansky

Nested Class Summary
static class NonReentrantLock.ReentranceException
           
 
Field Summary
protected  int held
           
protected  Transaction holdingTx
           
protected  Object lock
           
protected  Thread lockHolder
           
 
Constructor Summary
NonReentrantLock()
           
 
Method Summary
protected  boolean acquireNonReentrant(long waitTime, Transaction miTx)
           
protected  boolean acquireReentrant(long waitTime, Transaction miTx)
           
 boolean attempt(long waitTime, Transaction miTx, boolean nonReentrant)
           
 Object getResourceHolder()
           
 void release(boolean nonReentrant)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lockHolder

protected Thread lockHolder

lock

protected Object lock

held

protected volatile int held

holdingTx

protected Transaction holdingTx
Constructor Detail

NonReentrantLock

public NonReentrantLock()
Method Detail

getResourceHolder

public Object getResourceHolder()
Specified by:
getResourceHolder in interface org.jboss.util.deadlock.Resource

acquireNonReentrant

protected boolean acquireNonReentrant(long waitTime,
                                      Transaction miTx)
                               throws org.jboss.util.deadlock.ApplicationDeadlockException,
                                      InterruptedException,
                                      NonReentrantLock.ReentranceException
Throws:
org.jboss.util.deadlock.ApplicationDeadlockException
InterruptedException
NonReentrantLock.ReentranceException

acquireReentrant

protected boolean acquireReentrant(long waitTime,
                                   Transaction miTx)
                            throws org.jboss.util.deadlock.ApplicationDeadlockException,
                                   InterruptedException,
                                   NonReentrantLock.ReentranceException
Throws:
org.jboss.util.deadlock.ApplicationDeadlockException
InterruptedException
NonReentrantLock.ReentranceException

attempt

public boolean attempt(long waitTime,
                       Transaction miTx,
                       boolean nonReentrant)
                throws org.jboss.util.deadlock.ApplicationDeadlockException,
                       InterruptedException,
                       NonReentrantLock.ReentranceException
Throws:
org.jboss.util.deadlock.ApplicationDeadlockException
InterruptedException
NonReentrantLock.ReentranceException

release

public void release(boolean nonReentrant)


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.