bitronix.tm.twopc.executor
Class ConcurrentExecutor

java.lang.Object
  extended by bitronix.tm.twopc.executor.ConcurrentExecutor
All Implemented Interfaces:
Executor, Service
Direct Known Subclasses:
BackportConcurrentExecutor

public class ConcurrentExecutor
extends java.lang.Object
implements Executor

Abstraction of the java.util.concurrent JDK 1.5+ implementation.

© Bitronix Software

Author:
lorban

Constructor Summary
  ConcurrentExecutor()
           
protected ConcurrentExecutor(java.lang.String[] implementations)
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConcurrentExecutor

public ConcurrentExecutor()

ConcurrentExecutor

protected ConcurrentExecutor(java.lang.String[] implementations)
Method Detail

submit

public java.lang.Object submit(Job job)
Description copied from interface: Executor
Submit a job to be executed by the thread pool.

Specified by:
submit in interface Executor
Parameters:
job - the Runnable to execute.
Returns:
an object used to monitor the execution of the submitted Runnable.

waitFor

public void waitFor(java.lang.Object future,
                    long timeout)
Description copied from interface: Executor
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.

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

isDone

public boolean isDone(java.lang.Object future)
Description copied from interface: Executor
Check if the thread pool has terminated the execution of the job represented by a future.

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

isUsable

public boolean isUsable()
Description copied from interface: Executor
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.

Specified by:
isUsable in interface Executor
Returns:
true if the Executor can be used, false otherwise.

shutdown

public void shutdown()
Description copied from interface: Executor
Shutdown the thead pool.

Specified by:
shutdown in interface Executor
Specified by:
shutdown in interface Service