Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## gecco.util
Class SignalThread

    java.lang.Object
      java.lang.Thread
          gecco.util.SignalThread

All Implemented Interfaces:
  Runnable, SignalRunnable

Direct Known Subclasses:
  ActsOfGod, Clock

public class SignalThread
extends Thread
implements SignalRunnable

This subclass of `Thread` has been extended with signal facilities. Other threads may send signals to it, requesting that it terminate or pause execution. This class only implements mechanisms for supporting signals; it is up to the `run()` method to check regularly whether a signal has been received, and act upon it.

Author:
  Karl Hasselström

Field Summary

Fields inherited from class java.lang.Thread
`MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

Fields inherited from interface gecco.util.SignalRunnable
`SIGKILL, SIGNONE, SIGPAUSE, SIGQUIT, SIGRESUME`

Constructor Summary
`SignalThread()` Constructs a new thread.
`SignalThread(SignalRunnable target)` Constructs a new thread.
`SignalThread(SignalRunnable target, String name)` Constructs a new thread.
`SignalThread(String name)` Constructs a new thread.
`SignalThread(ThreadGroup group, SignalRunnable target)` Constructs a new thread.
`SignalThread(ThreadGroup group, SignalRunnable target, String name)` Constructs a new thread.
`SignalThread(ThreadGroup group, String name)` Constructs a new thread.

Method Summary
`static void` | `clearSignal()` This clears any pending signal for the current thread.
`static SignalThread` | `current()` Returns the object representing the currently executing signal thread.
`static void` | `pauseHandler()` This utility method will cause the thread to sleep as long as the currently pending signal is `SIGPAUSE` .
`void` | `sendSignal(int signal)` This sends a signal to the thread.
`static int` | `signalPending()` Returns the currently pending signal for the current thread.

Methods inherited from class java.lang.Thread
`activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, 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`

Methods inherited from interface java.lang.Runnable
`run`

Constructor Detail

### SignalThread

    public SignalThread()

  Constructs a new thread. Threads created this way must have overridden their `run()` method to actually do anything.

### SignalThread

    public SignalThread(SignalRunnable target)

  Constructs a new thread.

Parameters:
  `target` - The object whose `run()` method is called.

### SignalThread

    public SignalThread(SignalRunnable target,
                        String name)

  Constructs a new thread.

Parameters:
  `target` - The object whose `run()` method is called.
  `name` - The name of the new thread.

### SignalThread

    public SignalThread(String name)

  Constructs a new thread. Threads created this way must have overridden their `run()` method to actually do anything.

Parameters:
  `name` - The name of the new thread.

### SignalThread

    public SignalThread(ThreadGroup group,
                        SignalRunnable target)

  Constructs a new thread.

Parameters:
  `group` - The thread group.
  `target` - The object whose `run()` method is called.

### SignalThread

    public SignalThread(ThreadGroup group,
                        SignalRunnable target,
                        String name)

  Constructs a new thread.

Parameters:
  `group` - The thread group.
  `target` - The object whose `run()` method is called.
  `name` - The name of the new thread.

### SignalThread

    public SignalThread(ThreadGroup group,
                        String name)

  Constructs a new thread. Threads created this way must have overridden their `run()` method to actually do anything.

Parameters:
  `group` - The thread group.
  `name` - The name of the new thread.

Method Detail

### sendSignal

    public void sendSignal(int signal)

  This sends a signal to the thread. Signals with higher priority (lower value) take precedence over signals with lower priority (higher value) -- for example, `SIGQUIT` goes before `SIGRESUME`.

  Parameters:
    `signal` - The signal.

### current

    public static SignalThread current()
                                throws ClassCastException

  Returns the object representing the currently executing signal thread.

  Returns:
    The current SignalThread.
  Throws:
    `ClassCastException` - If the current thread is not a SignalThread.

### signalPending

    public static int signalPending()

  Returns the currently pending signal for the current thread. This is always `SIGNONE` if the thread isn't a `SignalThread` .

  Returns:
    The currently pending signal.

### clearSignal

    public static void clearSignal()

  This clears any pending signal for the current thread. Use this after you are finished handling a signal.

### pauseHandler

    public static void pauseHandler()

  This utility method will cause the thread to sleep as long as the currently pending signal is `SIGPAUSE` . When that is no longer the case, it will return immediately.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD