Package org.glassfish.grizzly.threadpool
Class SyncThreadPool
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- org.glassfish.grizzly.threadpool.AbstractThreadPool
-
- org.glassfish.grizzly.threadpool.SyncThreadPool
-
- All Implemented Interfaces:
Thread.UncaughtExceptionHandler,Executor,ExecutorService,MonitoringAware<ThreadPoolProbe>
public class SyncThreadPool extends AbstractThreadPool
ExecutorServiceimplementation, 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
Nested Classes Modifier and Type Class Description protected classSyncThreadPool.SyncThreadWorker-
Nested classes/interfaces inherited from class org.glassfish.grizzly.threadpool.AbstractThreadPool
AbstractThreadPool.Worker
-
-
Field Summary
Fields Modifier and Type Field Description protected intmaxQueuedTasks-
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
Constructors Constructor Description SyncThreadPool(ThreadPoolConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute(Runnable task)protected voidonWorkerExit(AbstractThreadPool.Worker worker)Method is called byAbstractThreadPool.Worker, when it's completingAbstractThreadPool.Worker.run()method execution, which in most cases means, that ThreadPool's thread will be released.protected voidpoisonAll()protected voidstartWorker(AbstractThreadPool.Worker worker)must hold statelock while calling this method.StringtoString()-
Methods inherited from class org.glassfish.grizzly.threadpool.AbstractThreadPool
afterExecute, awaitTermination, beforeExecute, drain, getConfig, getDefaultThreadFactory, getMonitoringConfig, getQueue, getSize, isShutdown, isTerminated, onMaxNumberOfThreadsReached, onTaskCancelled, 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
-
-
-
-
Constructor Detail
-
SyncThreadPool
public SyncThreadPool(ThreadPoolConfig config)
-
-
Method Detail
-
execute
public void execute(Runnable task)
-
startWorker
protected void startWorker(AbstractThreadPool.Worker worker)
Description copied from class:AbstractThreadPoolmust hold statelock while calling this method.- Overrides:
startWorkerin classAbstractThreadPool
-
onWorkerExit
protected void onWorkerExit(AbstractThreadPool.Worker worker)
Description copied from class:AbstractThreadPoolMethod is called byAbstractThreadPool.Worker, when it's completingAbstractThreadPool.Worker.run()method execution, which in most cases means, that ThreadPool's thread will be released. This method is called fromAbstractThreadPool.Worker's thread.- Overrides:
onWorkerExitin classAbstractThreadPool
-
poisonAll
protected void poisonAll()
- Overrides:
poisonAllin classAbstractThreadPool
-
toString
public String toString()
- Overrides:
toStringin classAbstractThreadPool
-
-