org.glassfish.grizzly.threadpool
Class SyncThreadPool

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by org.glassfish.grizzly.threadpool.AbstractThreadPool
          extended by org.glassfish.grizzly.threadpool.SyncThreadPool
All Implemented Interfaces:
java.lang.Thread.UncaughtExceptionHandler, java.util.concurrent.Executor, java.util.concurrent.ExecutorService, JmxMonitoringAware<ThreadPoolProbe>, MonitoringAware<ThreadPoolProbe>

public class SyncThreadPool
extends AbstractThreadPool

ExecutorService implementation, which function the similar way as former Grizzly 1.x Pipeline based thread pools. The SyncThreadPool is sychronized similar way as Grizzly 1.x Pipeline, which makes thread pool more accurate when deciding to create or not additional worker threads.

Author:
Alexey Stashok

Nested Class Summary
protected  class SyncThreadPool.SyncThreadWorker
           
 
Nested classes/interfaces inherited from class org.glassfish.grizzly.threadpool.AbstractThreadPool
AbstractThreadPool.Worker
 
Field Summary
protected  int maxQueuedTasks
           
 
Fields inherited from class org.glassfish.grizzly.threadpool.AbstractThreadPool
config, DEFAULT_IDLE_THREAD_KEEPALIVE_TIMEOUT, DEFAULT_MAX_TASKS_QUEUED, DEFAULT_MAX_THREAD_COUNT, DEFAULT_MIN_THREAD_COUNT, delayedQueue, monitoringConfig, poison, running, stateLock, transactionTimeoutMillis, workers
 
Constructor Summary
SyncThreadPool(ThreadPoolConfig config)
           
 
Method Summary
 boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit)
          
 void execute(java.lang.Runnable task)
           
 int getActiveThreadsCount()
           
 int getCurrentPoolSize()
           
 boolean isTerminated()
          
protected  void onWorkerExit(AbstractThreadPool.Worker worker)
          Method is called by AbstractThreadPool.Worker, when it's completing AbstractThreadPool.Worker.run() method execution, which in most cases means, that ThreadPool's thread will be released.
protected  void onWorkerStarted(AbstractThreadPool.Worker worker)
          Method is called by AbstractThreadPool.Worker, when it's starting AbstractThreadPool.Worker.run() method execution, which means, that ThreadPool's thread is getting active and ready to process tasks.
protected  void poisonAll()
           
 void start()
           
protected  void startWorker(AbstractThreadPool.Worker worker)
          must hold statelock while calling this method.
 void stop()
           
 java.lang.String toString()
           
 
Methods inherited from class org.glassfish.grizzly.threadpool.AbstractThreadPool
afterExecute, beforeExecute, drain, getConfig, getDefaultThreadFactory, getMonitoringConfig, getQueue, isShutdown, nextThreadId, onMaxNumberOfThreadsReached, onTaskCompletedEvent, onTaskDequeued, onTaskQueued, onTaskQueueOverflow, shutdown, shutdownNow, uncaughtException, validateNewPoolSize
 
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, wait, wait, wait
 

Field Detail

maxQueuedTasks

protected volatile int maxQueuedTasks
Constructor Detail

SyncThreadPool

public SyncThreadPool(ThreadPoolConfig config)
Method Detail

start

public void start()

stop

public void stop()

getCurrentPoolSize

public int getCurrentPoolSize()

getActiveThreadsCount

public int getActiveThreadsCount()

execute

public void execute(java.lang.Runnable task)

startWorker

protected void startWorker(AbstractThreadPool.Worker worker)
Description copied from class: AbstractThreadPool
must hold statelock while calling this method.

Overrides:
startWorker in class AbstractThreadPool

onWorkerStarted

protected void onWorkerStarted(AbstractThreadPool.Worker worker)
Description copied from class: AbstractThreadPool
Method is called by AbstractThreadPool.Worker, when it's starting AbstractThreadPool.Worker.run() method execution, which means, that ThreadPool's thread is getting active and ready to process tasks. This method is called from AbstractThreadPool.Worker's thread.

Overrides:
onWorkerStarted in class AbstractThreadPool

onWorkerExit

protected void onWorkerExit(AbstractThreadPool.Worker worker)
Description copied from class: AbstractThreadPool
Method is called by AbstractThreadPool.Worker, when it's completing AbstractThreadPool.Worker.run() method execution, which in most cases means, that ThreadPool's thread will be released. This method is called from AbstractThreadPool.Worker's thread.

Overrides:
onWorkerExit in class AbstractThreadPool

isTerminated

public boolean isTerminated()


poisonAll

protected void poisonAll()
Overrides:
poisonAll in class AbstractThreadPool

awaitTermination

public boolean awaitTermination(long timeout,
                                java.util.concurrent.TimeUnit unit)
                         throws java.lang.InterruptedException

Throws:
java.lang.InterruptedException

toString

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


Copyright © 2011 Oracle Corpration. All Rights Reserved.