Module org.glassfish.grizzly
Package org.glassfish.grizzly.threadpool
Class VirtualThreadExecutorService
java.lang.Object
java.util.concurrent.AbstractExecutorService
org.glassfish.grizzly.threadpool.VirtualThreadExecutorService
- All Implemented Interfaces:
AutoCloseable,Thread.UncaughtExceptionHandler,Executor,ExecutorService,ThreadPoolInfo
public class VirtualThreadExecutorService
extends AbstractExecutorService
implements ThreadPoolInfo, Thread.UncaughtExceptionHandler
- Author:
- mazhen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DefaultMonitoringConfig<ThreadPoolProbe> ThreadPool probes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long timeout, TimeUnit unit) static VirtualThreadExecutorServicestatic VirtualThreadExecutorServicevoidintintgetSize()booleanbooleanprotected voidMethod is called by AbstractThreadPool, when maximum number of worker threads is reached and task will need to wait in task queue, until one of the threads will be able to process it.protected voidonTaskCancelled(Runnable task) Method is called by a thread pool each time a dequeued task has been canceled instead of being processed.protected voidonTaskCompletedEvent(Runnable task) This method will be invoked when a the specifiedRunnablehas completed execution.protected voidonTaskDequeued(Runnable task) Method is called by a thread pool each time a task has been dequeued from a task queue.protected voidonTaskQueued(Runnable task) Method is called by a thread pool each time new task has been queued to a task queue.protected voidonWorkerExit(Thread thread) Method is called by, when it's completinginvalid reference
Workermethod execution, which in most cases means, that ThreadPool's thread will be released.invalid reference
Worker#run()protected voidonWorkerStarted(Thread thread) Method is called by, when it's startinginvalid reference
Workermethod execution, which means, that ThreadPool's thread is getting active and ready to process tasks.invalid reference
Worker#run()voidshutdown()voiduncaughtException(Thread thread, Throwable throwable) Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.concurrent.ExecutorService
close
-
Field Details
-
monitoringConfig
ThreadPool probes
-
-
Constructor Details
-
VirtualThreadExecutorService
-
-
Method Details
-
createInstance
-
createInstance
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNowin interfaceExecutorService
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService- Specified by:
isShutdownin interfaceThreadPoolInfo
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
execute
-
uncaughtException
- Specified by:
uncaughtExceptionin interfaceThread.UncaughtExceptionHandler
-
getSize
public int getSize()- Specified by:
getSizein interfaceThreadPoolInfo- Returns:
- the number of allocated threads in the thread pool
-
getConfig
- Specified by:
getConfigin interfaceThreadPoolInfo- Returns:
- the thread pool configuration
-
getMonitoringConfig
- Specified by:
getMonitoringConfigin interfaceThreadPoolInfo
-
getQueueSize
public int getQueueSize()- Specified by:
getQueueSizein interfaceThreadPoolInfo
-
onTaskCompletedEvent
This method will be invoked when a the specified
Runnablehas completed execution.- Parameters:
task- the unit of work that has completed processing
-
onWorkerStarted
Method is called by, when it's startinginvalid reference
Workermethod execution, which means, that ThreadPool's thread is getting active and ready to process tasks. This method is called frominvalid reference
Worker#run()'s thread.invalid reference
Worker- Parameters:
worker-
-
onWorkerExit
Method is called by, when it's completinginvalid reference
Workermethod execution, which in most cases means, that ThreadPool's thread will be released. This method is called frominvalid reference
Worker#run()'s thread.invalid reference
Worker- Parameters:
worker-
-
onMaxNumberOfThreadsReached
protected void onMaxNumberOfThreadsReached()Method is called by AbstractThreadPool, when maximum number of worker threads is reached and task will need to wait in task queue, until one of the threads will be able to process it. -
onTaskQueued
Method is called by a thread pool each time new task has been queued to a task queue.- Parameters:
task-
-
onTaskDequeued
Method is called by a thread pool each time a task has been dequeued from a task queue.- Parameters:
task-
-
onTaskCancelled
Method is called by a thread pool each time a dequeued task has been canceled instead of being processed.- Parameters:
task-
-