I would like to request an enhancement for the VirtualThreadDelegate code to improve its compatibility with JDK 21 and provide additional customization options. The current code is designed for JDK 21, but I believe there are opportunities to make it more robust and feature-rich.

Specifically, I propose the following enhancements:

Compatibility: Ensure that the code remains compatible with future JDK versions beyond JDK 21.

Customization Options: Add more customization options to the methods, allowing users to configure various aspects of virtual threads, such as daemon status, priority, stack size, and other attributes.

Error Handling: Introduce appropriate error handling and exception management to ensure reliable behavior in different scenarios.

Documentation: Improve the documentation for the VirtualThreadDelegate class and its methods, including examples and usage guidelines for developers.

Testing: Create comprehensive unit tests to verify the correctness of the code and its robustness under different conditions.

Performance Optimization: Consider analyzing the code for possible performance optimizations, especially if it's used in high-throughput or low-latency environments.

I believe that these enhancements will make the VirtualThreadDelegate code more versatile and reliable for our application. I am willing to contribute to these changes if the community agrees with this proposal. Your feedback and suggestions are highly appreciated.

Comment From: jhoeller

VirtualThreadDelegate is an internal class that isn't even public. We just use for it adapting between our JDK 17 baseline in the core module and our optional JDK 21 virtual threads support. As a consequence, that delegate class intentionally only supports exactly what we need to delegate to in SimpleAsyncTaskExecutor and VirtualThreadTaskExecutor.

For custom purposes, please use the Thread.ofVirtual()... builder API directly. If you buíld a .factory() there, you can also pass that custom ThreadFactory into existing extension points such as SimpleAsyncTaskExecutor.setThreadFactory.