bitronix.tm.twopc.executor
Interface Executor

All Superinterfaces:
Service
All Known Implementing Classes:
BackportConcurrentExecutor, ConcurrentExecutor, SimpleAsyncExecutor, SyncExecutor

public interface Executor
extends Service

Thread pool interface required by the two-phase commit logic.

© Bitronix Software

Author:
lorban

Method Summary
 boolean isDone(java.lang.Object future)
          Check if the thread pool has terminated the execution of the job represented by a future.
 boolean isUsable()
          Check if the thread pool can be used.
 void shutdown()
          Shutdown the thead pool.
 java.lang.Object submit(Job job)
          Submit a job to be executed by the thread pool.
 void waitFor(java.lang.Object future, long timeout)
          Wait for the job represented by the future to terminate.
 

Method Detail

submit

java.lang.Object submit(Job job)
Submit a job to be executed by the thread pool.

Parameters:
job - the Runnable to execute.
Returns:
an object used to monitor the execution of the submitted Runnable.

waitFor

void waitFor(java.lang.Object future,
             long timeout)
Wait for the job represented by the future to terminate. The call to this method will block until the job finished its execution or the specified timeout elapsed.

Parameters:
future - the future representing the job as returned by submit(bitronix.tm.twopc.executor.Job).
timeout - if the job did not finish during the specified timeout in milliseconds, this method returns anyway.

isDone

boolean isDone(java.lang.Object future)
Check if the thread pool has terminated the execution of the job represented by a future.

Parameters:
future - the future representing the job as returned by submit(bitronix.tm.twopc.executor.Job).
Returns:
true if the job is done, false otherwise.

isUsable

boolean isUsable()
Check if the thread pool can be used. The thread pool migh rely on an underlying implementation that may not be available. All other methods will throw a BitronixRuntimeException when called if this method returns false.

Returns:
true if the Executor can be used, false otherwise.

shutdown

void shutdown()
Shutdown the thead pool.

Specified by:
shutdown in interface Service