public abstract class

Lock

extends Object
java.lang.Object
   ↳ com.ericsson.research.trap.utils.Lock
Known Direct Subclasses

Class Overview

Port of the Java Lock class to allow 1.4 and earlier compatibility.

Summary

Public Methods
static Lock createLock()
Creates a new Lock using the most applicable implementation.
abstract void lock()
Attempts to lock the lock, blocking execution if someone else already owns it.
abstract void lockInterruptibly()
Attempts to lock, allowing InterruptedExceptions to occur.
abstract boolean tryLock()
Attempts to lock.
abstract boolean tryLock(long waitTime)
Attempts to lock, waiting up to waitTime msec.
abstract void unlock()
Unlocks a currently owned lock.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Lock createLock ()

Creates a new Lock using the most applicable implementation.

Returns
  • A newly instantiated Lock.

public abstract void lock ()

Attempts to lock the lock, blocking execution if someone else already owns it.

public abstract void lockInterruptibly ()

Attempts to lock, allowing InterruptedExceptions to occur.

public abstract boolean tryLock ()

Attempts to lock. Does not block execution.

Returns
  • true if a lock was acquired, false otherwise.

public abstract boolean tryLock (long waitTime)

Attempts to lock, waiting up to waitTime msec.

Parameters
waitTime The number of msec to wait max for a lock.
Returns
  • true if a lock was acquired, false otherwise.
Throws
InterruptedException If the thread was interrupted during the wait.

public abstract void unlock ()

Unlocks a currently owned lock.