org.openrdf.repository.object.util
Class ManagedThreadPool

java.lang.Object
  extended by org.openrdf.repository.object.util.ManagedThreadPool
All Implemented Interfaces:
java.util.concurrent.Executor, java.util.concurrent.ExecutorService, ThreadPoolMXBean
Direct Known Subclasses:
ManagedScheduledThreadPool

public class ManagedThreadPool
extends java.lang.Object
implements java.util.concurrent.ExecutorService, ThreadPoolMXBean

Exposes ThreadPoolExecutor properties in an MXBean.

Author:
James Leigh

Constructor Summary
  ManagedThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue, java.lang.String name, boolean daemon)
           
  ManagedThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue, java.lang.String name, boolean daemon, java.util.concurrent.RejectedExecutionHandler handler)
           
  ManagedThreadPool(java.lang.String name, boolean daemon)
           
protected ManagedThreadPool(java.util.concurrent.ThreadPoolExecutor delegate)
           
 
Method Summary
 boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit)
           
 void clearQueue()
           
 void execute(java.lang.Runnable command)
           
 int getActiveCount()
           
 long getCompletedTaskCount()
           
 int getCorePoolSize()
           
protected  java.util.concurrent.ThreadPoolExecutor getDelegate()
           
 long getKeepAliveTime()
           
 int getLargestPoolSize()
           
 int getMaximumPoolSize()
           
 int getPoolSize()
           
 java.lang.String[] getQueueDescription()
           
 int getQueueRemainingCapacity()
           
 int getQueueSize()
           
 long getTaskCount()
           
 void interruptWorkers()
           
<T> java.util.List<java.util.concurrent.Future<T>>
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
           
<T> java.util.List<java.util.concurrent.Future<T>>
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)
           
<T> T
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
           
<T> T
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)
           
 boolean isAllowsCoreThreadTimeOut()
           
 boolean isContinueExistingPeriodicTasksAfterShutdownPolicy()
           
 boolean isExecuteExistingDelayedTasksAfterShutdownPolicy()
           
 boolean isShutdown()
           
 boolean isTerminated()
           
 boolean isTerminating()
           
 void purge()
           
 void runAllInQueue()
           
 void runNextInQueue()
           
 void setAllowCoreThreadTimeOut(boolean allow)
           
 void setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean policy)
           
 void setCorePoolSize(int corePoolSize)
           
protected  void setDelegate(java.util.concurrent.ThreadPoolExecutor delegate)
           
 void setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean policy)
           
 void setKeepAliveTime(long seconds)
           
 void setMaximumPoolSize(int maximumPoolSize)
           
 void shutdown()
           
 java.util.List<java.lang.Runnable> shutdownNow()
           
 void startAllCoreThreads()
           
 void startCoreThread()
           
<T> java.util.concurrent.Future<T>
submit(java.util.concurrent.Callable<T> task)
           
 java.util.concurrent.Future<?> submit(java.lang.Runnable task)
           
<T> java.util.concurrent.Future<T>
submit(java.lang.Runnable task, T result)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ManagedThreadPool

public ManagedThreadPool(java.lang.String name,
                         boolean daemon)

ManagedThreadPool

public ManagedThreadPool(int corePoolSize,
                         int maximumPoolSize,
                         long keepAliveTime,
                         java.util.concurrent.TimeUnit unit,
                         java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
                         java.lang.String name,
                         boolean daemon)

ManagedThreadPool

public ManagedThreadPool(int corePoolSize,
                         int maximumPoolSize,
                         long keepAliveTime,
                         java.util.concurrent.TimeUnit unit,
                         java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
                         java.lang.String name,
                         boolean daemon,
                         java.util.concurrent.RejectedExecutionHandler handler)

ManagedThreadPool

protected ManagedThreadPool(java.util.concurrent.ThreadPoolExecutor delegate)
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setCorePoolSize

public void setCorePoolSize(int corePoolSize)
Specified by:
setCorePoolSize in interface ThreadPoolMXBean

shutdown

public void shutdown()
Specified by:
shutdown in interface java.util.concurrent.ExecutorService
Specified by:
shutdown in interface ThreadPoolMXBean

shutdownNow

public java.util.List<java.lang.Runnable> shutdownNow()
Specified by:
shutdownNow in interface java.util.concurrent.ExecutorService

interruptWorkers

public void interruptWorkers()
                      throws java.lang.InterruptedException
Specified by:
interruptWorkers in interface ThreadPoolMXBean
Throws:
java.lang.InterruptedException

clearQueue

public void clearQueue()
Specified by:
clearQueue in interface ThreadPoolMXBean

getKeepAliveTime

public long getKeepAliveTime()
Specified by:
getKeepAliveTime in interface ThreadPoolMXBean

setKeepAliveTime

public void setKeepAliveTime(long seconds)
Specified by:
setKeepAliveTime in interface ThreadPoolMXBean

getQueueDescription

public java.lang.String[] getQueueDescription()
Specified by:
getQueueDescription in interface ThreadPoolMXBean

runAllInQueue

public void runAllInQueue()
Specified by:
runAllInQueue in interface ThreadPoolMXBean

runNextInQueue

public void runNextInQueue()
Specified by:
runNextInQueue in interface ThreadPoolMXBean

getQueueRemainingCapacity

public int getQueueRemainingCapacity()
Specified by:
getQueueRemainingCapacity in interface ThreadPoolMXBean

getQueueSize

public int getQueueSize()
Specified by:
getQueueSize in interface ThreadPoolMXBean

isAllowsCoreThreadTimeOut

public boolean isAllowsCoreThreadTimeOut()
Specified by:
isAllowsCoreThreadTimeOut in interface ThreadPoolMXBean

isContinueExistingPeriodicTasksAfterShutdownPolicy

public boolean isContinueExistingPeriodicTasksAfterShutdownPolicy()
Specified by:
isContinueExistingPeriodicTasksAfterShutdownPolicy in interface ThreadPoolMXBean

isExecuteExistingDelayedTasksAfterShutdownPolicy

public boolean isExecuteExistingDelayedTasksAfterShutdownPolicy()
Specified by:
isExecuteExistingDelayedTasksAfterShutdownPolicy in interface ThreadPoolMXBean

setAllowCoreThreadTimeOut

public void setAllowCoreThreadTimeOut(boolean allow)
Specified by:
setAllowCoreThreadTimeOut in interface ThreadPoolMXBean

setContinueExistingPeriodicTasksAfterShutdownPolicy

public void setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean policy)
Specified by:
setContinueExistingPeriodicTasksAfterShutdownPolicy in interface ThreadPoolMXBean

setExecuteExistingDelayedTasksAfterShutdownPolicy

public void setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean policy)
Specified by:
setExecuteExistingDelayedTasksAfterShutdownPolicy in interface ThreadPoolMXBean

startAllCoreThreads

public void startAllCoreThreads()
Specified by:
startAllCoreThreads in interface ThreadPoolMXBean

startCoreThread

public void startCoreThread()
Specified by:
startCoreThread in interface ThreadPoolMXBean

getActiveCount

public int getActiveCount()
Specified by:
getActiveCount in interface ThreadPoolMXBean

getCompletedTaskCount

public long getCompletedTaskCount()
Specified by:
getCompletedTaskCount in interface ThreadPoolMXBean

getCorePoolSize

public int getCorePoolSize()
Specified by:
getCorePoolSize in interface ThreadPoolMXBean

getPoolSize

public int getPoolSize()
Specified by:
getPoolSize in interface ThreadPoolMXBean

getTaskCount

public long getTaskCount()
Specified by:
getTaskCount in interface ThreadPoolMXBean

isTerminating

public boolean isTerminating()
Specified by:
isTerminating in interface ThreadPoolMXBean

getLargestPoolSize

public int getLargestPoolSize()
Specified by:
getLargestPoolSize in interface ThreadPoolMXBean

getMaximumPoolSize

public int getMaximumPoolSize()
Specified by:
getMaximumPoolSize in interface ThreadPoolMXBean

purge

public void purge()
Specified by:
purge in interface ThreadPoolMXBean

setMaximumPoolSize

public void setMaximumPoolSize(int maximumPoolSize)
Specified by:
setMaximumPoolSize in interface ThreadPoolMXBean

awaitTermination

public boolean awaitTermination(long timeout,
                                java.util.concurrent.TimeUnit unit)
                         throws java.lang.InterruptedException
Specified by:
awaitTermination in interface java.util.concurrent.ExecutorService
Throws:
java.lang.InterruptedException

execute

public void execute(java.lang.Runnable command)
Specified by:
execute in interface java.util.concurrent.Executor

invokeAll

public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
                                                                    long timeout,
                                                                    java.util.concurrent.TimeUnit unit)
                                                         throws java.lang.InterruptedException
Specified by:
invokeAll in interface java.util.concurrent.ExecutorService
Throws:
java.lang.InterruptedException

invokeAll

public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
                                                         throws java.lang.InterruptedException
Specified by:
invokeAll in interface java.util.concurrent.ExecutorService
Throws:
java.lang.InterruptedException

invokeAny

public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
                       long timeout,
                       java.util.concurrent.TimeUnit unit)
            throws java.lang.InterruptedException,
                   java.util.concurrent.ExecutionException,
                   java.util.concurrent.TimeoutException
Specified by:
invokeAny in interface java.util.concurrent.ExecutorService
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException

invokeAny

public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
            throws java.lang.InterruptedException,
                   java.util.concurrent.ExecutionException
Specified by:
invokeAny in interface java.util.concurrent.ExecutorService
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException

isShutdown

public boolean isShutdown()
Specified by:
isShutdown in interface java.util.concurrent.ExecutorService
Specified by:
isShutdown in interface ThreadPoolMXBean

isTerminated

public boolean isTerminated()
Specified by:
isTerminated in interface java.util.concurrent.ExecutorService
Specified by:
isTerminated in interface ThreadPoolMXBean

submit

public <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
Specified by:
submit in interface java.util.concurrent.ExecutorService

submit

public <T> java.util.concurrent.Future<T> submit(java.lang.Runnable task,
                                                 T result)
Specified by:
submit in interface java.util.concurrent.ExecutorService

submit

public java.util.concurrent.Future<?> submit(java.lang.Runnable task)
Specified by:
submit in interface java.util.concurrent.ExecutorService

getDelegate

protected java.util.concurrent.ThreadPoolExecutor getDelegate()

setDelegate

protected void setDelegate(java.util.concurrent.ThreadPoolExecutor delegate)


Copyright © 2004-2011 James Leigh Services Inc.. All Rights Reserved.