JBoss Threads 2.0.0.GA

org.jboss.threads
Class JBossThreadPoolExecutor

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by java.util.concurrent.ThreadPoolExecutor
          extended by org.jboss.threads.JBossThreadPoolExecutor
All Implemented Interfaces:
Executor, ExecutorService, BlockingExecutor, BlockingExecutorService, BoundedQueueThreadPoolExecutorMBean, BoundedThreadPoolExecutorMBean, ThreadExecutorMBean, ThreadPoolExecutorMBean, ShutdownListenable

public final class JBossThreadPoolExecutor
extends ThreadPoolExecutor
implements BlockingExecutorService, BoundedQueueThreadPoolExecutorMBean, ShutdownListenable


Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
 
Constructor Summary
JBossThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
           
JBossThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)
           
JBossThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
           
JBossThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)
           
 
Method Summary
<A> void
addShutdownListener(EventListener<A> shutdownListener, A attachment)
          Add a shutdown listener.
 void execute(Runnable task)
          Executes the given command at some time in the future.
 void executeBlocking(Runnable task)
          Execute a task, blocking until it can be accepted, or until the calling thread is interrupted.
 void executeBlocking(Runnable task, long timeout, TimeUnit unit)
          Execute a task, blocking until it can be accepted, a timeout elapses, or the calling thread is interrupted.
 void executeNonBlocking(Runnable task)
          Execute a task, without blocking.
 int getCoreThreads()
           
 int getCurrentThreadCount()
           
 long getKeepAliveTime()
           
 int getLargestThreadCount()
           
 int getMaxThreads()
           
 int getRejectedCount()
           
 RejectedExecutionHandler getRejectedExecutionHandler()
           
 boolean isAllowCoreThreadTimeout()
           
 boolean isBlocking()
           
 void setAllowCoreThreadTimeout(boolean allow)
           
 void setBlocking(boolean blocking)
           
 void setCoreThreads(int newSize)
           
 void setKeepAliveTime(long milliseconds)
           
 void setMaxThreads(int newSize)
           
 void setRejectedExecutionHandler(RejectedExecutionHandler handler)
           
protected  void terminated()
           
 
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setThreadFactory, shutdown, shutdownNow
 
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submit
 

Constructor Detail

JBossThreadPoolExecutor

public JBossThreadPoolExecutor(int corePoolSize,
                               int maximumPoolSize,
                               long keepAliveTime,
                               TimeUnit unit,
                               BlockingQueue<Runnable> workQueue)

JBossThreadPoolExecutor

public JBossThreadPoolExecutor(int corePoolSize,
                               int maximumPoolSize,
                               long keepAliveTime,
                               TimeUnit unit,
                               BlockingQueue<Runnable> workQueue,
                               ThreadFactory threadFactory)

JBossThreadPoolExecutor

public JBossThreadPoolExecutor(int corePoolSize,
                               int maximumPoolSize,
                               long keepAliveTime,
                               TimeUnit unit,
                               BlockingQueue<Runnable> workQueue,
                               RejectedExecutionHandler handler)

JBossThreadPoolExecutor

public JBossThreadPoolExecutor(int corePoolSize,
                               int maximumPoolSize,
                               long keepAliveTime,
                               TimeUnit unit,
                               BlockingQueue<Runnable> workQueue,
                               ThreadFactory threadFactory,
                               RejectedExecutionHandler handler)
Method Detail

execute

public void execute(Runnable task)
Description copied from interface: BlockingExecutor
Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation. The call may block or not block, depending on the configuration of the executor.

Specified by:
execute in interface Executor
Specified by:
execute in interface BlockingExecutor
Overrides:
execute in class ThreadPoolExecutor
Parameters:
task - the task to submit

executeBlocking

public void executeBlocking(Runnable task)
                     throws RejectedExecutionException,
                            InterruptedException
Description copied from interface: BlockingExecutor
Execute a task, blocking until it can be accepted, or until the calling thread is interrupted.

Specified by:
executeBlocking in interface BlockingExecutor
Parameters:
task - the task to submit
Throws:
StoppedExecutorException - if the executor was shut down before the task was accepted
ThreadCreationException - if a thread could not be created for some reason
RejectedExecutionException - if execution is rejected for some other reason
InterruptedException - if the current thread was interrupted before the task could be accepted

executeBlocking

public void executeBlocking(Runnable task,
                            long timeout,
                            TimeUnit unit)
                     throws RejectedExecutionException,
                            InterruptedException
Description copied from interface: BlockingExecutor
Execute a task, blocking until it can be accepted, a timeout elapses, or the calling thread is interrupted.

Specified by:
executeBlocking in interface BlockingExecutor
Parameters:
task - the task to submit
timeout - the amount of time to wait
unit - the unit of time
Throws:
ExecutionTimedOutException - if the timeout elapsed before a task could be accepted
StoppedExecutorException - if the executor was shut down before the task was accepted
ThreadCreationException - if a thread could not be created for some reason
RejectedExecutionException - if execution is rejected for some other reason
InterruptedException - if the current thread was interrupted before the task could be accepted

executeNonBlocking

public void executeNonBlocking(Runnable task)
                        throws RejectedExecutionException
Description copied from interface: BlockingExecutor
Execute a task, without blocking.

Specified by:
executeNonBlocking in interface BlockingExecutor
Parameters:
task - the task to submit
Throws:
StoppedExecutorException - if the executor was shut down before the task was accepted
ThreadCreationException - if a thread could not be created for some reason
RejectedExecutionException - if execution is rejected for some other reason

getLargestThreadCount

public int getLargestThreadCount()
Specified by:
getLargestThreadCount in interface ThreadExecutorMBean

isAllowCoreThreadTimeout

public boolean isAllowCoreThreadTimeout()
Specified by:
isAllowCoreThreadTimeout in interface BoundedQueueThreadPoolExecutorMBean

setAllowCoreThreadTimeout

public void setAllowCoreThreadTimeout(boolean allow)
Specified by:
setAllowCoreThreadTimeout in interface BoundedQueueThreadPoolExecutorMBean

getMaxThreads

public int getMaxThreads()
Specified by:
getMaxThreads in interface ThreadPoolExecutorMBean

setMaxThreads

public void setMaxThreads(int newSize)
Specified by:
setMaxThreads in interface ThreadPoolExecutorMBean

getCoreThreads

public int getCoreThreads()
Specified by:
getCoreThreads in interface BoundedQueueThreadPoolExecutorMBean

setCoreThreads

public void setCoreThreads(int newSize)
Specified by:
setCoreThreads in interface BoundedQueueThreadPoolExecutorMBean

getKeepAliveTime

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

setKeepAliveTime

public void setKeepAliveTime(long milliseconds)
Specified by:
setKeepAliveTime in interface ThreadPoolExecutorMBean

getCurrentThreadCount

public int getCurrentThreadCount()
Specified by:
getCurrentThreadCount in interface ThreadExecutorMBean

getRejectedCount

public int getRejectedCount()
Specified by:
getRejectedCount in interface ThreadExecutorMBean

isBlocking

public boolean isBlocking()
Specified by:
isBlocking in interface BoundedThreadPoolExecutorMBean

setBlocking

public void setBlocking(boolean blocking)
Specified by:
setBlocking in interface BoundedThreadPoolExecutorMBean

getRejectedExecutionHandler

public RejectedExecutionHandler getRejectedExecutionHandler()
Overrides:
getRejectedExecutionHandler in class ThreadPoolExecutor

setRejectedExecutionHandler

public void setRejectedExecutionHandler(RejectedExecutionHandler handler)
Overrides:
setRejectedExecutionHandler in class ThreadPoolExecutor

addShutdownListener

public <A> void addShutdownListener(EventListener<A> shutdownListener,
                                    A attachment)
Add a shutdown listener. If the target object is already shut down, the listener is invoked directly.

Specified by:
addShutdownListener in interface ShutdownListenable
Type Parameters:
A - the attachment type
Parameters:
shutdownListener - the listener
attachment - the attachment value to pass to the listener

terminated

protected void terminated()
Overrides:
terminated in class ThreadPoolExecutor

JBoss Threads 2.0.0.GA

Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.