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 synchronized 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, stateLockCondition, transactionTimeoutMillis, workers
 
Constructor Summary
SyncThreadPool(ThreadPoolConfig config)
           
 
Method Summary
 void execute(java.lang.Runnable task)
           
 int getActiveThreadsCount()
           
 int getCurrentPoolSize()
           
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 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, awaitTermination, beforeExecute, drain, getConfig, getDefaultThreadFactory, getMonitoringConfig, getQueue, isShutdown, isTerminated, nextThreadId, onMaxNumberOfThreadsReached, onTaskCompletedEvent, onTaskDequeued, onTaskQueued, onTaskQueueOverflow, onWorkerStarted, 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

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

poisonAll

protected void poisonAll()
Overrides:
poisonAll in class AbstractThreadPool

toString

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


Copyright © 2012 Oracle Corporation. All Rights Reserved.