net.sf.xbus.base.core.timeoutcall
Class TimedCallable

java.lang.Object
  extended by net.sf.xbus.base.core.timeoutcall.ThreadFactoryUser
      extended by net.sf.xbus.base.core.timeoutcall.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.

Version:
1.0

[ Introduction to this package. ]

Author:
Joseph Bowbeer

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.xbus.base.core.timeoutcall.ThreadFactoryUser
ThreadFactoryUser.DefaultThreadFactory
 
Field Summary
 
Fields inherited from class net.sf.xbus.base.core.timeoutcall.ThreadFactoryUser
threadFactory_
 
Constructor Summary
TimedCallable(Callable function, long millis)
           
 
Method Summary
 java.lang.Object call()
          Performs some action that returns a result or throws an exception
 void stop()
          Stops the running call
 
Methods inherited from class net.sf.xbus.base.core.timeoutcall.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)
Method Detail

call

public java.lang.Object call()
                      throws XException
Description copied from interface: Callable
Performs some action that returns a result or throws an exception

Specified by:
call in interface Callable
Throws:
XException

stop

public void stop()
Description copied from interface: Callable
Stops the running call

Specified by:
stop in interface Callable