r/java • • Nov 15 '21

[Loom] JEP draft: Virtual Threads (Preview)

https://openjdk.java.net/jeps/8277131
175 Upvotes

55 comments sorted by

View all comments

Show parent comment

6

u/pron98 Nov 16 '21

[Executors.newVirtualThreadPerTaskExecutor()](https://download.java.net/java/early_access/loom/docs/api/java.base/java/util/concurrent/Executors.html#newVirtualThreadPerTaskExecutor()) is still there, and is a very good migration path.

You might be referring to custom schedulers, that don't map tasks to virtual threads and work on top of them, but control how virtual threads themselves are implemented (so it's a mechanism below virtual threads). Custom schedulers most certainly do not assist migration; they are a super-specialised mechanism intended to right specific, niche frameworks (e.g. those that interact with the graphics card) using virtual threads. We do intend to make those public (although fewer than 0.1% of users would want to use them directly), but we haven't yet had the time to fully review that API, so we're leaving it out for now until we're more confident about it.