I’m currently working on a project where I need to handle blocking I/O operations efficiently without tying up essential system resources. I’m using Project Reactor and specifically the Schedulers.boundedElastic() scheduler. I understand that starting from version 3.6.0, boundedElastic() offers two different implementations based on the setup:
- ExecutorService-based
- Thread-per-task-based (VirtualThread)
Given these options, I’m unclear about when to choose the ExecutorService-based implementation versus the VirtualThread-based implementation. For simplicity, I would tend to use VirtualThreads, and I wonder if this should be the default choice starting with Java 21.
Could someone clarify the scenarios or considerations for choosing one implementation over the other? In which scenarios would one implementation be preferred over the other? Is it advisable to default to using VirtualThreads in a Java 21+ environment?