org.glassfish.grizzly.threadpool
Class DefaultThreadPool

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by java.util.concurrent.ThreadPoolExecutor
          extended by org.glassfish.grizzly.threadpool.DefaultThreadPool
All Implemented Interfaces:
Thread.UncaughtExceptionHandler, Executor, ExecutorService, ExtendedThreadPool

public class DefaultThreadPool
extends ThreadPoolExecutor
implements ExtendedThreadPool, Thread.UncaughtExceptionHandler

Thread Pool implementation, based on ThreadPoolExecutor

Author:
Alexey Stashok

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
 
Field Summary
protected  AttributeBuilder attributeBuilder
          AttributeBuilder to index WorkerThread attributes
 
Constructor Summary
DefaultThreadPool()
           
DefaultThreadPool(int corePoolSize, int maximumPoolSize, int maxTasksCount, long keepAliveTime, TimeUnit unit)
           
 
Method Summary
protected  void afterExecute(Runnable r, Throwable t)
           
protected  void beforeExecute(Thread t, Runnable r)
           
 AttributeBuilder getAttributeBuilder()
           
 int getMaxQueuedTasksCount()
           
 String getName()
           
 int getQueuedTasksCount()
           
 int getQueueSize()
          Returns the number of tasks, which are currently waiting in the queue.
 void setAttributeBuilder(AttributeBuilder attributeBuilder)
           
 void setMaxQueuedTasksCount(int maxTasksCount)
           
 void setName(String name)
           
 void start()
           
 void stop()
           
 void uncaughtException(Thread thread, Throwable throwable)
           
 
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated
 
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 org.glassfish.grizzly.threadpool.ExtendedThreadPool
getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getTaskCount, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize
 

Field Detail

attributeBuilder

protected AttributeBuilder attributeBuilder
AttributeBuilder to index WorkerThread attributes

Constructor Detail

DefaultThreadPool

public DefaultThreadPool()

DefaultThreadPool

public DefaultThreadPool(int corePoolSize,
                         int maximumPoolSize,
                         int maxTasksCount,
                         long keepAliveTime,
                         TimeUnit unit)
Method Detail

getQueuedTasksCount

public int getQueuedTasksCount()

getMaxQueuedTasksCount

public int getMaxQueuedTasksCount()

setMaxQueuedTasksCount

public void setMaxQueuedTasksCount(int maxTasksCount)

getName

public String getName()
Specified by:
getName in interface ExtendedThreadPool

setName

public void setName(String name)
Specified by:
setName in interface ExtendedThreadPool

getQueueSize

public int getQueueSize()
Description copied from interface: ExtendedThreadPool
Returns the number of tasks, which are currently waiting in the queue.

Specified by:
getQueueSize in interface ExtendedThreadPool
Returns:
the number of tasks, which are currently waiting in the queue.

start

public void start()

stop

public void stop()

getAttributeBuilder

public AttributeBuilder getAttributeBuilder()
Specified by:
getAttributeBuilder in interface ExtendedThreadPool

setAttributeBuilder

public void setAttributeBuilder(AttributeBuilder attributeBuilder)
Specified by:
setAttributeBuilder in interface ExtendedThreadPool

uncaughtException

public void uncaughtException(Thread thread,
                              Throwable throwable)
Specified by:
uncaughtException in interface Thread.UncaughtExceptionHandler

beforeExecute

protected void beforeExecute(Thread t,
                             Runnable r)
Overrides:
beforeExecute in class ThreadPoolExecutor

afterExecute

protected void afterExecute(Runnable r,
                            Throwable t)
Overrides:
afterExecute in class ThreadPoolExecutor


Copyright © 2009 SUN Microsystems. All Rights Reserved.