Enhancement Description
The ThreadPoolExecutor-implementations we currently use do not support virtual threads. Theoretically, we could use a ThreadPoolExecutor which creates virtual threads instead of platform threads, like this:
ExecutorService executor = new ThreadPoolExecutor(
1, // corePoolSize (irrelevant for virtual threads)
1, // maximumPoolSize
0L, TimeUnit.SECONDS, // keepAliveTime (irrelevant)
new PriorityBlockingQueue<>(1000)(), // workQueue
Thread.ofVirtual().factory() // Virtual Thread Factory
);
However, this is probably not ideal because we no longer need a classic pool for virtual threads: for each new task, a virtual thread is simply created and released again once the task is complete.
Furthermore, we still need to support priorities in task processing.
We should build an implementation for the ExecutorServiceFactory that builds an ExecutorService that supports virtual threads and uses a PriorityBlockingQueue for priority-based task processing.
Current Behaviour
The ExecutorServiceFactory creates classic ThreadPoolExecutors that uses platform-threads.
Wanted Behaviour
The ExecutorServiceFactory creates a custom ExecutorService-implementation that uses virtual threads and supports priority-based task processing.
Enhancement Description
The
ThreadPoolExecutor-implementations we currently use do not support virtual threads. Theoretically, we could use aThreadPoolExecutorwhich creates virtual threads instead of platform threads, like this:However, this is probably not ideal because we no longer need a classic pool for virtual threads: for each new task, a virtual thread is simply created and released again once the task is complete.
Furthermore, we still need to support priorities in task processing.
We should build an implementation for the
ExecutorServiceFactorythat builds anExecutorServicethat supports virtual threads and uses aPriorityBlockingQueuefor priority-based task processing.Current Behaviour
The
ExecutorServiceFactorycreates classicThreadPoolExecutorsthat uses platform-threads.Wanted Behaviour
The
ExecutorServiceFactorycreates a customExecutorService-implementation that uses virtual threads and supports priority-based task processing.