## com.sun.grizzly.util
Class WorkerThreadImpl

    java.lang.Object
      java.lang.Thread
          com.sun.grizzly.util.WorkerThread
              com.sun.grizzly.util.WorkerThreadImpl

All Implemented Interfaces:
  Runnable

    public class WorkerThreadImpl

extends WorkerThread

Simple worker thread used for processing HTTP requests. All threads are synchronized using a `Pipeline` object

Author:
  Jean-Francois Arcand

Nested Class Summary

Nested classes/interfaces inherited from class java.lang.Thread
`Thread.State, Thread.UncaughtExceptionHandler`

Field Summary
`protected boolean` `execute` Looing variable.
`protected Pipeline<Callable>` `pipeline` The `Pipeline` on which this thread synchronize.
`protected Runnable` `target` What will be run.
`protected static ThreadGroup` `threadGroup` The `ThreadGroup` used.

Fields inherited from class com.sun.grizzly.util.WorkerThread
`byteBuffer, inputBB, outputBB, sslEngine`

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

Constructor Summary
`WorkerThreadImpl(Pipeline<Callable> pipeline, String name)` Create a Thread that will synchronizes/block on `Pipeline` instance.
`WorkerThreadImpl(Pipeline<Callable> pipeline, String name, int initialByteBufferSize)` Create a Thread that will synchronizes/block on `Pipeline` instance.
`WorkerThreadImpl(ThreadGroup threadGroup, Runnable runnable)` Create a Thread that will synchronizes/block on `Pipeline` instance.
`WorkerThreadImpl(ThreadGroup threadGroup, Runnable runnable, int initialByteBufferSize)` Create a Thread that will synchronizes/block on `Pipeline` instance.

Method Summary
`void` `attach(ThreadAttachment threadAttachment)` Attach the ThreadAttachment to this instance.
`ThreadAttachment` `detach()` Detach the current set of attributes (state) associated with this instance.
`ThreadAttachment` `getAttachment()` Get the current set of attributes (state) associated with this instance.
`ByteBufferFactory.ByteBufferType` `getByteBufferType()` The `ByteBufferType` used to create the `ByteBuffer` associated with this object.
`protected void` `reset()`
`void` `run()` Execute a `Task`.
`void` `setByteBufferType(ByteBufferFactory.ByteBufferType byteBufferType)` Set the `ByteBufferType` to use when creating the `ByteBuffer` associated with this object.
`void` `terminate()` Stop this thread.
`ThreadAttachment` `updateAttachment(int mode)` Updates Thread associated attachment according to the passed mode.

Methods inherited from class com.sun.grizzly.util.WorkerThread
`getByteBuffer, getInputBB, getOutputBB, getSSLEngine, setByteBuffer, setInputBB, setOutputBB, setSSLEngine`

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

### target

    protected Runnable target

  What will be run.

### pipeline

    protected Pipeline<Callable> pipeline

  The `Pipeline` on which this thread synchronize.

### execute

    protected volatile boolean execute

  Looing variable.

### threadGroup

    protected static final ThreadGroup threadGroup

  The `ThreadGroup` used.

Constructor Detail

### WorkerThreadImpl

    public WorkerThreadImpl(ThreadGroup threadGroup,
                            Runnable runnable)

  Create a Thread that will synchronizes/block on `Pipeline` instance.

  Parameters:
    `threadGroup` - `ThreadGroup`
    `runnable` - `Runnable`

### WorkerThreadImpl

    public WorkerThreadImpl(ThreadGroup threadGroup,
                            Runnable runnable,
                            int initialByteBufferSize)

  Create a Thread that will synchronizes/block on `Pipeline` instance.

  Parameters:
    `threadGroup` - `ThreadGroup`
    `runnable` - `Runnable`
    `initialByteBufferSize` - initial `ByteBuffer` size

### WorkerThreadImpl

    public WorkerThreadImpl(Pipeline<Callable> pipeline,
                            String name)

  Create a Thread that will synchronizes/block on `Pipeline` instance.

  Parameters:
    `pipeline` - `Pipeline`
    `name` - `String`

### WorkerThreadImpl

    public WorkerThreadImpl(Pipeline<Callable> pipeline,
                            String name,
                            int initialByteBufferSize)

  Create a Thread that will synchronizes/block on `Pipeline` instance.

  Parameters:
    `pipeline` - `Pipeline`
    `name` - `String`
    `initialByteBufferSize` - initial `ByteBuffer` size

Method Detail

### run

    public void run()

  Execute a `Task`.

  Specified by:
    `run` in interface `Runnable`
  Overrides:
    `run` in class `Thread`

### terminate

    public void terminate()

  Stop this thread. If this Thread is performing atask, the task will be completed.

  Specified by:
    `terminate` in class `WorkerThread`

### updateAttachment

    public ThreadAttachment updateAttachment(int mode)

  Description copied from class: `WorkerThread`
  Updates Thread associated attachment according to the passed mode.

  Specified by:
    `updateAttachment` in class `WorkerThread`
  Returns:
    updated ThreadAttachment

### getAttachment

    public ThreadAttachment getAttachment()

  Description copied from class: `WorkerThread`
  Get the current set of attributes (state) associated with this instance. Unlike detach(), this method doesn't clear the WorkerThread attributes.

  Specified by:
    `getAttachment` in class `WorkerThread`
  Returns:
    the Thread associated ThreadAttachment

### detach

    public ThreadAttachment detach()

  Description copied from class: `WorkerThread`
  Detach the current set of attributes (state) associated with this instance. Method will re-create all the ByteBuffers associated with this thread.

  Specified by:
    `detach` in class `WorkerThread`
  Returns:
    a new ThreadAttachment

### attach

    public void attach(ThreadAttachment threadAttachment)

  Description copied from class: `WorkerThread`
  Attach the ThreadAttachment to this instance. This will configure this Thread attributes like ByteBuffer, SSLEngine, etc.

  Specified by:
    `attach` in class `WorkerThread`

### getByteBufferType

    public ByteBufferFactory.ByteBufferType getByteBufferType()

  The `ByteBufferType` used to create the `ByteBuffer` associated with this object.

  Returns:
    The `ByteBufferType` used to create the `ByteBuffer` associated with this object.

### setByteBufferType

    public void setByteBufferType(ByteBufferFactory.ByteBufferType byteBufferType)

  Set the `ByteBufferType` to use when creating the `ByteBuffer` associated with this object.

  Parameters:
    `byteBufferType` - The ByteBuffer type.

### reset

    protected void reset()

  Overrides:
    `reset` in class `WorkerThread`

Copyright © 2008 SUN Microsystems. All Rights Reserved.