org.apache.excalibur.thread.impl
Class DefaultThreadControl

java.lang.Object
  extended by org.apache.excalibur.thread.impl.DefaultThreadControl
All Implemented Interfaces:
org.apache.excalibur.thread.ThreadControl

final class DefaultThreadControl
extends java.lang.Object
implements org.apache.excalibur.thread.ThreadControl

Default implementation of ThreadControl interface. Is used by worker thread to supply control information to the clients of thread pool.

Author:
Avalon Development Team

Field Summary
private  java.lang.Thread m_thread
           
private  java.lang.Throwable m_throwable
           
 
Constructor Summary
protected DefaultThreadControl(java.lang.Thread thread)
          Construct thread control for a specific thread.
 
Method Summary
protected  void finish(java.lang.Throwable throwable)
          Method called by thread to release control.
 java.lang.Throwable getThrowable()
          Retrieve throwable that caused thread to cease execution.
 void interrupt()
          Call Thread.interrupt() on thread being controlled.
 void interupt()
           
 boolean isFinished()
          Determine if thread has finished execution
 void join(long milliSeconds)
          Wait for specified time for thread to complete it's work.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_thread

private java.lang.Thread m_thread

m_throwable

private java.lang.Throwable m_throwable
Constructor Detail

DefaultThreadControl

protected DefaultThreadControl(java.lang.Thread thread)
Construct thread control for a specific thread.

Parameters:
thread - the thread to control
Method Detail

join

public void join(long milliSeconds)
          throws java.lang.IllegalStateException,
                 java.lang.InterruptedException
Wait for specified time for thread to complete it's work.

Specified by:
join in interface org.apache.excalibur.thread.ThreadControl
Parameters:
milliSeconds - the duration in milliseconds to wait until the thread has finished work
Throws:
java.lang.IllegalStateException - if isValid() == false
java.lang.InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.

interupt

public void interupt()
              throws java.lang.IllegalStateException,
                     java.lang.SecurityException
Throws:
java.lang.IllegalStateException
java.lang.SecurityException

interrupt

public void interrupt()
               throws java.lang.IllegalStateException,
                      java.lang.SecurityException
Call Thread.interrupt() on thread being controlled.

Specified by:
interrupt in interface org.apache.excalibur.thread.ThreadControl
Throws:
java.lang.IllegalStateException - if isValid() == false
java.lang.SecurityException - if caller does not have permission to call interupt()

isFinished

public boolean isFinished()
Determine if thread has finished execution

Specified by:
isFinished in interface org.apache.excalibur.thread.ThreadControl
Returns:
true if thread is finished, false otherwise

getThrowable

public java.lang.Throwable getThrowable()
Retrieve throwable that caused thread to cease execution. Only valid when true == isFinished()

Specified by:
getThrowable in interface org.apache.excalibur.thread.ThreadControl
Returns:
the throwable that caused thread to finish execution

finish

protected void finish(java.lang.Throwable throwable)
Method called by thread to release control.

Parameters:
throwable - Throwable that caused thread to complete (may be null)