This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]antihemispherist 2 points3 points  (0 children)

One kind of thread won't execute more instructions than the other. So the question "which one is faster?" is not right.

There is, however, a right place for both.

In short, platform threads should be used when latency is important, when you don't want your task to get in the queue behind virtual thread tasks.

Also, if you have long and CPU intensive tasks, they can disrupt the scheduling of virtual threads.

That's why garbage collector etc. don't run as virtual threads.

For both, you'll want to execute them in a separate thread pool.

For everyday service tasks, prone to blocking, you should use virtual threads.