Top Description Inners Fields Constructors Methods
net.sf.ehcache.transaction.xa.processor

public Class XAThreadPool

extends Object
Class Inheritance
Imports
java.util.concurrent.BrokenBarrierException, .Callable, .CyclicBarrier, .ExecutionException, .ExecutorService, .Executors

Fast and minimalistic thread pool from which threads can be reserved and used many times until they are manually released.
Author
Ludovic Orban

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
XAThreadPool.MultiRunner

Pooled thread wrapper which allows reuse of the same thread

Field Summary

Modifier and TypeField and Description
private final ExecutorService

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public synchronized XAThreadPool.MultiRunner

Returns:

a MultiRunner which wraps the reserved thread
getMultiRunner
()

Reserve a thread from the pool

public synchronized void
shutdown()

Shutdown the thread pool and release all resources

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

executorback to summary
private final ExecutorService executor

Constructor Detail

XAThreadPoolback to summary
public XAThreadPool()

Method Detail

getMultiRunnerback to summary
public synchronized XAThreadPool.MultiRunner getMultiRunner()

Reserve a thread from the pool

Returns:XAThreadPool.MultiRunner

a MultiRunner which wraps the reserved thread

shutdownback to summary
public synchronized void shutdown()

Shutdown the thread pool and release all resources

net.sf.ehcache.transaction.xa.processor back to summary

public final Class XAThreadPool.MultiRunner

extends Object
implements Runnable
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.transaction.xa.processor.XAThreadPool.MultiRunner
All Implemented Interfaces
java.lang.Runnable

Pooled thread wrapper which allows reuse of the same thread

Field Summary

Modifier and TypeField and Description
private volatile Callable<V>
private final CyclicBarrier
private volatile Exception
private volatile boolean
private volatile Object
private final CyclicBarrier

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

the Object returned by the Callable
execute
(Callable<V>
The Callable to execute
callable
)

Execute a Callable on the wrapped thread and return its result

public void
release()

Release the wrapped thread back the the containing thread pool

public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

callableback to summary
private volatile Callable<V> callable
endBarrierback to summary
private final CyclicBarrier endBarrier
exceptionback to summary
private volatile Exception exception
releasedback to summary
private volatile boolean released
resultback to summary
private volatile Object result
startBarrierback to summary
private final CyclicBarrier startBarrier

Constructor Detail

MultiRunnerback to summary
private MultiRunner()

Method Detail

executeback to summary
public Object execute(Callable<V> callable) throws ExecutionException, InterruptedException

Execute a Callable on the wrapped thread and return its result

Parameters
callable:Callable<V>

The Callable to execute

Returns:Object

the Object returned by the Callable

Exceptions
ExecutionException:
thrown when something went wrong during execution
InterruptedException:
thrown when the executing thread got interrupted
releaseback to summary
public void release()

Release the wrapped thread back the the containing thread pool

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.