Apache Tomcat 7.0.22

org.apache.tomcat.util.threads
Class DedicatedThreadExecutor

java.lang.Object
  extended by org.apache.tomcat.util.threads.DedicatedThreadExecutor

public class DedicatedThreadExecutor
extends java.lang.Object

A utility class to execute a Callable in a dedicated thread. It can be used either with an instance to reuse the same thread for each call to execute(Callable) or with the static method executeInOwnThread(Callable). When using an instance, shutdown() must be called when the instance is no longer needed to dispose of the dedicated thread.


Constructor Summary
DedicatedThreadExecutor()
           
 
Method Summary
<V> V
execute(java.util.concurrent.Callable<V> callable)
          Executes the given Callable with the thread spawned for the current DedicatedThreadExecutor instance, and returns its result.
static
<V> V
executeInOwnThread(java.util.concurrent.Callable<V> callable)
          Executes the given Callable in a new thread and returns the result after the thread is stopped.
 void shutdown()
          Stops the dedicated thread and waits for its death.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DedicatedThreadExecutor

public DedicatedThreadExecutor()
Method Detail

execute

public <V> V execute(java.util.concurrent.Callable<V> callable)
Executes the given Callable with the thread spawned for the current DedicatedThreadExecutor instance, and returns its result.

Type Parameters:
V - the type of the returned value
Parameters:
callable -
Returns:
the completed result

shutdown

public void shutdown()
Stops the dedicated thread and waits for its death.


executeInOwnThread

public static <V> V executeInOwnThread(java.util.concurrent.Callable<V> callable)
Executes the given Callable in a new thread and returns the result after the thread is stopped.

Type Parameters:
V -
Parameters:
callable -
Returns:
the completed result

Apache Tomcat 7.0.22

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.