Trying to handle how many virtual threads may run in parallel. Think about throttle and how to avoid overloading external systems.
that is the way we are used to: create a fixed thread pool (or a cached thread pool) and submit jobs
it is that easy: just create an ExecutorService with Executors.newVirtualThreadPerTaskExecutor()
and submit your jobs.
but you may process thousands or millions of processes concurrently and end up overloading an external system.
that's the same implementation as 1 but using Project's Loom Virtual Threads implementation with fixed number of virtual threads.
tried something different customizing ThreadPoolExecutor
but at the end of the day, it is the same as the 3.
handles the maximum number of concurrent tasks executed in parallel by using a Semaphore to limit virtual threads.