Forward Computing and Control Pty. Ltd.
Threads Package V1.0.3

2005/04/11

au.com.forward.threads
Class ThreadEvent

java.lang.Object
  extended by java.util.EventObject
      extended by au.com.forward.threads.ThreadEvent
All Implemented Interfaces:
java.io.Serializable

public class ThreadEvent
extends java.util.EventObject
implements java.io.Serializable

This class encapsulates a Thread termination event.  See ThreadReturn for more details.

This class contains the source thread, the type of termination and the return Object or Throwable.  It is used as the argument to the ThreadListener methods.

Mods: 8th March 2003 - added implements Serializable added processing for Object arg.

Author:
matthew ford
See Also:
Serialized Form

Field Summary
static int ERROR
          This type indicates there was some error in the thread execution or monitoring.
static int INTERRUPTED
          This type indicates the thread saved either an InterruptedException or a ClosedByInterruptException.
static int RETURN
          This type indicates the thread died normally.
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
ThreadEvent(java.lang.Thread source, java.lang.Object obj)
          The thread died normally and saved this object for return.
ThreadEvent(java.lang.Thread source, java.lang.Throwable e)
          The thread saved some Throwable or some error occurred during the monitoring.
 
Method Summary
 java.lang.Object getObject()
          Gets the Object saved by the thread.
 java.lang.Thread getThread()
          Gets the source Thread of this event.
 java.lang.Throwable getThrowable()
          Gets the Throwable object saved by the thread.
 int getType()
          Gets the type of this ThreadEvent
 java.lang.String toString()
          Returns a string containing a description of this ThreadEvent.
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RETURN

public static final int RETURN
This type indicates the thread died normally. 

getObject() returns the object saved by this thread, if any.
getThrowable() will return null.

See Also:
getType(), Constant Field Values

INTERRUPTED

public static final int INTERRUPTED
This type indicates the thread saved either an InterruptedException or a ClosedByInterruptException

getThrowable() returns either InterruptedException or ClosedByInterruptException
getObject() returns the exception as an Object.

See Also:
getType(), Constant Field Values

ERROR

public static final int ERROR
This type indicates there was some error in the thread execution or monitoring. 

getThrowable() returns the associated Throwable as a Throwable
getObject() returns the associated Throwable as an Object.

See Also:
getType(), Constant Field Values
Constructor Detail

ThreadEvent

public ThreadEvent(java.lang.Thread source,
                   java.lang.Object obj)
The thread died normally and saved this object for return.  getType() will return RETURN

Parameters:
source - the Thread being monitored.
obj - the Object saved by the thread or null if none saved.

ThreadEvent

public ThreadEvent(java.lang.Thread source,
                   java.lang.Throwable e)
The thread saved some Throwable or some error occurred during the monitoring.  getType() will return INTERRUPTED if the Throwable is either InterruptedException or ClosedByInterruptException otherwise it will return ERROR

Parameters:
source - the Thread being monitored.
e - the Throwable describing the error.
Method Detail

getType

public int getType()
Gets the type of this ThreadEvent

Returns:
the type, RETURN, INTERRUPTED or ERROR

getThread

public java.lang.Thread getThread()
Gets the source Thread of this event.

Returns:
the Thread being monitored.

getThrowable

public java.lang.Throwable getThrowable()
Gets the Throwable object saved by the thread.  Returns null if the thread did not save a Throwable object.

Returns:
the Throwable object or null if none saved.

getObject

public java.lang.Object getObject()
Gets the Object saved by the thread.  If the thread saved a Throwable object that object will be returned.

Returns:
The Object saved by the thread or null if none saved.

toString

public java.lang.String toString()
Returns a string containing a description of this ThreadEvent.

Overrides:
toString in class java.util.EventObject
Returns:
description of this ThreadEvent.

Forward Computing and Control Pty. Ltd.
Threads Package V1.0.3

2005/04/11

Copyright ©2002-5, Forward Computing and Control Pty. Ltd
ACN 003 669 994   NSW Australia,   All Rights Reserved.