Class 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$
    Author:
    Neil Smyth, Mudit Goel
    Pt.AcceptedRating:
    Yellow (mudit)
    Pt.ProposedRating:
    Green (mudit)
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Constructor Description
      NotifyThread​(java.lang.Object lock)
      Construct a thread to be used call notifyAll() on a set of locks.
      NotifyThread​(java.util.LinkedList locks)
      Construct a thread to be used call notifyAll() on a set of locks.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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