JBoss Threads 2.0.0.GA-redhat-2

org.jboss.threads
Class QueuelessExecutor

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

public final class QueuelessExecutor
extends AbstractExecutorService
implements BlockingExecutorService, BoundedThreadPoolExecutorMBean, ShutdownListenable

A queueless thread pool. If one or more threads are waiting for work when a task is submitted, it will be used. Otherwise, if fewer than the maximum threads are started, a new thread is created.


Constructor Summary
QueuelessExecutor(ThreadFactory threadFactory, DirectExecutor taskExecutor, Executor handoffExecutor, long keepAliveTime)
           
 
Method Summary
<A> void
addShutdownListener(EventListener<A> shutdownListener, A attachment)
          Add a shutdown listener.
 boolean awaitTermination(long timeout, TimeUnit unit)
           
 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 getCurrentThreadCount()
           
 Executor getHandoffExecutor()
           
 long getKeepAliveTime()
           
 int getLargestThreadCount()
           
 int getMaxThreads()
           
 int getRejectedCount()
           
 boolean isBlocking()
           
 boolean isShutdown()
           
 boolean isTerminated()
           
 void setBlocking(boolean blocking)
           
 void setHandoffExecutor(Executor handoffExecutor)
           
 void setKeepAliveTime(long milliseconds)
           
 void setMaxThreads(int newSize)
           
 void shutdown()
           
 List<Runnable> 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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.concurrent.ExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submit
 

Constructor Detail

QueuelessExecutor

public QueuelessExecutor(ThreadFactory threadFactory,
                         DirectExecutor taskExecutor,
                         Executor handoffExecutor,
                         long keepAliveTime)
Method Detail

getMaxThreads

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

setMaxThreads

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

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

getLargestThreadCount

public int getLargestThreadCount()
Specified by:
getLargestThreadCount 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

getHandoffExecutor

public Executor getHandoffExecutor()

setHandoffExecutor

public void setHandoffExecutor(Executor handoffExecutor)

shutdown

public void shutdown()
Specified by:
shutdown in interface ExecutorService

awaitTermination

public boolean awaitTermination(long timeout,
                                TimeUnit unit)
                         throws InterruptedException
Specified by:
awaitTermination in interface ExecutorService
Throws:
InterruptedException

shutdownNow

public List<Runnable> shutdownNow()
Specified by:
shutdownNow in interface ExecutorService

isShutdown

public boolean isShutdown()
Specified by:
isShutdown in interface ExecutorService

isTerminated

public boolean isTerminated()
Specified by:
isTerminated in interface ExecutorService

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
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

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

JBoss Threads 2.0.0.GA-redhat-2

Copyright © 2012 JBoss by Red Hat. All Rights Reserved.