Extension SDK 10.1.2

oracle.javatools.parser.util
Class SimpleLock

java.lang.Object
  extended byoracle.javatools.parser.util.SimpleLock

public final class SimpleLock
extends java.lang.Object

The SimpleLock is a simple implementation of an exclusive lock. It does not support nested lock/unlock pairs from the same thread. It does not guarantee fairness. It does not detect thread abandonment (i.e. thread exits while holding lock.) It does not verify that a thread actually holds the lock when it tries to unlock the lock.


Constructor Summary
SimpleLock()
          Construct a new SimpleLock instance.
 
Method Summary
 boolean isLocked()
          Fetches whether the lock is currently being held.
 void lock()
          Request the lock.
 void unlock()
          Releases the lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleLock

public SimpleLock()
Construct a new SimpleLock instance. The lock is created in the unlocked state by default.

Method Detail

lock

public void lock()
Request the lock. If the lock is currently being held, this will block until it is available. If the lock is available, it will mark the lock as locked and unavailable.


unlock

public void unlock()
Releases the lock. This will make the lock available to other requesters, and wake up a single sleeping requester.


isLocked

public boolean isLocked()
Fetches whether the lock is currently being held.

Returns:
true if the lock is currently being held

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.