de.hunsicker.util.concurrent
Class TimedCallable

java.lang.Object
  |
  +--de.hunsicker.util.concurrent.ThreadFactoryUser
        |
        +--de.hunsicker.util.concurrent.TimedCallable
All Implemented Interfaces:
Callable

public class TimedCallable
extends ThreadFactoryUser
implements Callable

TimedCallable runs a Callable function for a given length of time. The function is run in its own thread. If the function completes in time, its result is returned; otherwise the thread is interrupted and an InterruptedException is thrown.

Note: TimedCallable will always return within the given time limit (modulo timer inaccuracies), but whether or not the worker thread stops in a timely fashion depends on the interrupt handling in the Callable function's implementation.

This class was taken from the util.concurrent package written by Doug Lea. See http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html for an introduction to this package.

Version:
1.0
Author:
Joseph Bowbeer, Doug Lea

Nested Class Summary
 
Nested classes inherited from class de.hunsicker.util.concurrent.ThreadFactoryUser
ThreadFactoryUser.DefaultThreadFactory
 
Field Summary
 
Fields inherited from class de.hunsicker.util.concurrent.ThreadFactoryUser
threadFactory_
 
Constructor Summary
TimedCallable(Callable function, long millis)
          Creates a new TimedCallable object.
 
Method Summary
 java.lang.Object call()
          DOCUMENT ME!
 
Methods inherited from class de.hunsicker.util.concurrent.ThreadFactoryUser
getThreadFactory, setThreadFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimedCallable

public TimedCallable(Callable function,
                     long millis)
Creates a new TimedCallable object.

Parameters:
function - DOCUMENT ME!
millis - DOCUMENT ME!
Method Detail

call

public java.lang.Object call()
                      throws java.lang.Exception
DOCUMENT ME!

Specified by:
call in interface Callable
Returns:
DOCUMENT ME!
Throws:
java.lang.Exception - DOCUMENT ME!


Copyright © 1997-2005 Jalopy. All Rights Reserved.