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 Details

  • Constructor Details

    • VirtualThreadExecutorService

      protected VirtualThreadExecutorService(ThreadPoolConfig config)
  • Method Details

    • createInstance

      public static VirtualThreadExecutorService createInstance()
    • createInstance

      public static VirtualThreadExecutorService createInstance(ThreadPoolConfig cfg)
    • shutdown

      public void shutdown()
      Specified by:
      shutdown in interface ExecutorService
    • shutdownNow

      public List<Runnable> shutdownNow()
      Specified by:
      shutdownNow in interface ExecutorService
    • isShutdown

      public boolean isShutdown()
      Specified by:
      isShutdown in interface ExecutorService
      Specified by:
      isShutdown in interface ThreadPoolInfo
    • isTerminated

      public boolean isTerminated()
      Specified by:
      isTerminated in interface ExecutorService
    • awaitTermination

      public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
      Specified by:
      awaitTermination in interface ExecutorService
      Throws:
      InterruptedException
    • execute

      public void execute(Runnable task)
      Specified by:
      execute in interface Executor
    • uncaughtException

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

      public int getSize()
      Specified by:
      getSize in interface ThreadPoolInfo
      Returns:
      the number of allocated threads in the thread pool
    • getConfig

      public ThreadPoolConfig getConfig()
      Specified by:
      getConfig in interface ThreadPoolInfo
      Returns:
      the thread pool configuration
    • getMonitoringConfig

      public DefaultMonitoringConfig<ThreadPoolProbe> getMonitoringConfig()
      Specified by:
      getMonitoringConfig in interface ThreadPoolInfo
    • getQueueSize

      public int getQueueSize()
      Specified by:
      getQueueSize in interface ThreadPoolInfo
    • onTaskCompletedEvent

      protected void onTaskCompletedEvent(Runnable task)

      This method will be invoked when a the specified Runnable has completed execution.

      Parameters:
      task - the unit of work that has completed processing
    • onWorkerStarted

      protected void onWorkerStarted(Thread thread)
      Method is called by
      invalid reference
      Worker
      , when it's starting
      invalid reference
      Worker#run()
      method execution, which means, that ThreadPool's thread is getting active and ready to process tasks. This method is called from
      invalid reference
      Worker
      's thread.
      Parameters:
      worker -
    • onWorkerExit

      protected void onWorkerExit(Thread thread)
      Method is called by
      invalid reference
      Worker
      , when it's completing
      invalid reference
      Worker#run()
      method execution, which in most cases means, that ThreadPool's thread will be released. This method is called from
      invalid reference
      Worker
      's thread.
      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

      protected void onTaskQueued(Runnable task)
      Method is called by a thread pool each time new task has been queued to a task queue.
      Parameters:
      task -
    • onTaskDequeued

      protected void onTaskDequeued(Runnable task)
      Method is called by a thread pool each time a task has been dequeued from a task queue.
      Parameters:
      task -
    • onTaskCancelled

      protected void onTaskCancelled(Runnable task)
      Method is called by a thread pool each time a dequeued task has been canceled instead of being processed.
      Parameters:
      task -