com.streambase.sb.operator

## Class Operator.OperatorThread

- java.lang.Object
- - java.lang.Thread
  - - com.streambase.sb.operator.Operator.OperatorThread

- All Implemented Interfaces:
    Runnable
  Enclosing class:
    Operator

      public class Operator.OperatorThread
      extends Thread

  The thread that wraps an operator runnable

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `Thread.State, Thread.UncaughtExceptionHandler`

  - ### Field Summary

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OperatorThread(String name, Runnable operatorRunnable, boolean shouldInterrupt, boolean synchronizedShutdown)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) int` | `getNextState()` Get next state
    `(package private) void` | `postStateChange(int state)` Request that the operator thread switch into a new state.
    `void` | `run()` Run method of this operator thread.
    `(package private) boolean` | `shouldInterrupt()` Get should interrupt?
    `boolean` | `shouldRun()` Implement state request responses of this operator thread.
    `(package private) void` | `shutdown()` Explicitly set the state of the thread to shutdown.
    `(package private) void` | `waitForAcceptance()` Block until the operator thread has successfully switched into the new state requested by postStateChange.

    - ### Methods inherited from class java.lang.Thread

      `activeCount, checkAccess, clone, 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

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### OperatorThread

          OperatorThread(String name,
                         Runnable operatorRunnable,
                         boolean shouldInterrupt,
                         boolean synchronizedShutdown)

      Constructor
      Parameters:
        `name` - Thread name
        `operatorRunnable` - Runnable
        `shouldInterrupt` - Should interrupt?
        `synchronizedShutdown` - Synchronized shutdown?

  - ### Method Detail

    - #### run

          public void run()

      Run method of this operator thread. This starts the operator runnable's run method and, upon exit, either accepts the SHUTDOWN state request, or goes silently.
      Specified by:
        `run` in interface `Runnable`
      Overrides:
        `run` in class `Thread`

    - #### shouldInterrupt

          boolean shouldInterrupt()

      Get should interrupt?
      Returns:
        true to interrupt, false otherwise

    - #### shouldRun

          public boolean shouldRun()

      Implement state request responses of this operator thread.
      Returns:
        true to run, false otherwise

    - #### getNextState

          int getNextState()

      Get next state
      Returns:
        State

    - #### postStateChange

          void postStateChange(int state)

      Request that the operator thread switch into a new state.

      `Operator.OperatorThread.waitForAcceptance()` must be called before another state change can be posted.

      This method must be called from the main thread.

      Parameters:
        `state` - New state

    - #### waitForAcceptance

          void waitForAcceptance()
                          throws StreamBaseException

      Block until the operator thread has successfully switched into the new state requested by postStateChange.

      This must be must be called from the main thread.

      Throws:
        `StreamBaseException` - If timed out.

    - #### shutdown

          void shutdown()

      Explicitly set the state of the thread to shutdown. Used only when the Operator fails.

Copyright © 2015–2018 Cloud Software Group, Inc.. All rights reserved.