ptolemy.actor.process
Class NotifyThread

java.lang.Object
  extended by java.lang.Thread
      extended by ptolemy.actor.process.NotifyThread
All Implemented Interfaces:
java.lang.Runnable

public class NotifyThread
extends java.lang.Thread

Helper thread for calling notifyAll() on a single lock or a LinkedList of locks. Since this is a new thread without any locks, calling notifyAll from this thread reduces the possibility of deadlocks.

To use this to wake up any threads waiting on a lock, create a new instance of this class with a LinkedList of lock objects (or single lock) to call notifyAll() on.

Since:
Ptolemy II 0.2
Version:
$Id: NotifyThread.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Neil Smyth, Mudit Goel
Accepted Rating:
Yellow (mudit)
Proposed Rating:
Green (mudit)

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  java.lang.Object _lock
           
private  java.util.LinkedList _locks
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
NotifyThread(java.util.LinkedList locks)
          Construct a thread to be used call notifyAll() on a set of locks.
NotifyThread(java.lang.Object lock)
          Construct a thread to be used call notifyAll() on a set of locks.
 
Method Summary
 void run()
          Call NotifyAll() on the lock object (or objects) passed to this class in its constructor.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_locks

private java.util.LinkedList _locks

_lock

private java.lang.Object _lock
Constructor Detail

NotifyThread

public NotifyThread(java.util.LinkedList locks)
Construct a thread to be used call notifyAll() on a set of locks.

Parameters:
locks - The set of locks to call notifyAll() on.

NotifyThread

public NotifyThread(java.lang.Object lock)
Construct a thread to be used call notifyAll() on a set of locks.

Parameters:
lock - The lock to call notifyAll() on.
Method Detail

run

public void run()
Call NotifyAll() on the lock object (or objects) passed to this class in its constructor.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread