Class PtolemyThread

  • All Implemented Interfaces:
    java.lang.Runnable, Debuggable
    Direct Known Subclasses:
    ActiveActorManager, ProcessThread, PtestWorkspace, TestPtolemyThread

    public class PtolemyThread
    extends java.lang.Thread
    implements Debuggable
    PtolemyThread PtolemyThread extends Thread by adding rudimentary debugging capability.
    Since:
    Ptolemy II 0.2
    Version:
    $Id$
    Author:
    Lukito Muliadi, contributor: Edward A. Lee
    Pt.AcceptedRating:
    Green (liuj)
    Pt.ProposedRating:
    Green (lmuliadi)
    • Nested Class Summary

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

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

      Fields 
      Modifier and Type Field Description
      protected boolean _debugging
      Flag that is true if there are debug listeners.
      protected java.util.LinkedList _debugListeners
      The list of DebugListeners registered with this object.
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Constructor Description
      PtolemyThread()
      Construct a new PtolemyThread object.
      PtolemyThread​(java.lang.Runnable target)
      Construct a new PtolemyThread object.
      PtolemyThread​(java.lang.Runnable target, java.lang.String name)
      Construct a new PtolemyThread object.
      PtolemyThread​(java.lang.String name)
      Construct a new PtolemyThread object.
      PtolemyThread​(java.lang.ThreadGroup group, java.lang.Runnable target)
      Construct a new PtolemyThread object.
      PtolemyThread​(java.lang.ThreadGroup group, java.lang.Runnable target, java.lang.String name)
      Construct a new PtolemyThread object so that it has target as its run object, has the specified name as its name, and belongs to the thread group referred to by group.
      PtolemyThread​(java.lang.ThreadGroup group, java.lang.String name)
      Construct a new PtolemyThread object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void _debug​(java.lang.String message)
      Send a debug message to all debug listeners that have registered.
      protected void _debug​(DebugEvent event)
      Send a debug event to all debug listeners that have registered.
      void addDebugListener​(DebugListener listener)
      Append a listener to the current set of debug listeners.
      void removeDebugListener​(DebugListener listener)
      Unregister a debug listener.
      • 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, run, 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
    • Field Detail

      • _debugging

        protected volatile boolean _debugging
        Flag that is true if there are debug listeners.
        Since:
        Ptolemy II 2.3
      • _debugListeners

        protected java.util.LinkedList _debugListeners
        The list of DebugListeners registered with this object.
        Since:
        Ptolemy II 2.3
    • Constructor Detail

      • PtolemyThread

        public PtolemyThread()
        Construct a new PtolemyThread object. This constructor has the same effect as PtolemyThread(null, null, generatedName), where generatedName is a newly generated name. Automatically generated names are of the form "Thread-"+n, where n is an integer.
      • PtolemyThread

        public PtolemyThread​(java.lang.Runnable target)
        Construct a new PtolemyThread object. This constructor has the same effect as PtolemyThread(null, target, generatedName), where generatedName is a newly generated name. Automatically generated names are of the form "Thread-"+n, where n is an integer.
        Parameters:
        target - The object whose run method is called.
      • PtolemyThread

        public PtolemyThread​(java.lang.Runnable target,
                             java.lang.String name)
        Construct a new PtolemyThread object. This constructor has the same effect as PtolemyThread(null, target, name)
        Parameters:
        target - The object whose run method is called.
        name - The name of the new thread.
      • PtolemyThread

        public PtolemyThread​(java.lang.String name)
        Construct a new PtolemyThread object. This constructor has the same effect as PtolemyThread(null, null, name)
        Parameters:
        name - The name of the new thread.
      • PtolemyThread

        public PtolemyThread​(java.lang.ThreadGroup group,
                             java.lang.Runnable target)
        Construct a new PtolemyThread object. This constructor has the same effect as PtolemyThread(group, target, generatedName), where generatedName is a newly generated name. Automatically generated names are of the form "Thread-"+n, where n is an integer.
        Parameters:
        group - The thread group
        target - The object whose run method is called.
      • PtolemyThread

        public PtolemyThread​(java.lang.ThreadGroup group,
                             java.lang.Runnable target,
                             java.lang.String name)
        Construct a new PtolemyThread object so that it has target as its run object, has the specified name as its name, and belongs to the thread group referred to by group.
        Parameters:
        group - The thread group.
        target - The object whose run method is called.
        name - The name of the new thread.
        Throws:
        java.lang.SecurityException - If the superclass constructor throws it.
      • PtolemyThread

        public PtolemyThread​(java.lang.ThreadGroup group,
                             java.lang.String name)
        Construct a new PtolemyThread object. This constructor has the same effect as PtolemyThread(group, null, name).
        Parameters:
        group - The thread group.
        name - The name of the new thread.
    • Method Detail

      • addDebugListener

        public void addDebugListener​(DebugListener listener)
        Append a listener to the current set of debug listeners. If the listener is already in the set, do not add it again.
        Specified by:
        addDebugListener in interface Debuggable
        Parameters:
        listener - The listener to which to send debug messages.
        Since:
        Ptolemy II 2.3
        See Also:
        removeDebugListener(DebugListener)
      • removeDebugListener

        public void removeDebugListener​(DebugListener listener)
        Unregister a debug listener. If the specified listener has not been previously registered, then do nothing.
        Specified by:
        removeDebugListener in interface Debuggable
        Parameters:
        listener - The listener to remove from the list of listeners to which debug messages are sent.
        Since:
        Ptolemy II 2.3
        See Also:
        addDebugListener(DebugListener)
      • _debug

        protected final void _debug​(DebugEvent event)
        Send a debug event to all debug listeners that have registered.
        Parameters:
        event - The event.
        Since:
        Ptolemy II 2.3
      • _debug

        protected final void _debug​(java.lang.String message)
        Send a debug message to all debug listeners that have registered. By convention, messages should not include a newline at the end. The newline will be added by the listener, if appropriate. Note that using this method could be fairly expensive if the message is constructed from parts, and that this expense will be incurred regardless of whether there are actually any debug listeners. Thus, you should avoid, if possible, constructing the message from parts.
        Parameters:
        message - The message.
        Since:
        Ptolemy II 2.3