Hacker News new | past | comments | ask | show | jobs | submit login

> Also, what is the story with preemption - if a virtual thread spins in an infinite loop, will it effectively hog the carrier thread or can it be descheduled?

As I understood it, there's no preemption. You're supposed to not do busy waiting on virtual threads (and better not do it at all, use wait-notify or a barrier or whatever). Virtual threads are for I/O-bound tasks. For CPU-bound tasks you'd want an OS thread per CPU core anyway.




They did implement pre-emption at some point and there are parts of that still in the code. It's intended to let you more easily manage load e.g. by de-scheduling complicated batch jobs that are low priority and then re-scheduling when the service is under lighter load. But it won't ship as public API as a part of Loom, maybe it will never ship (generally once OpenJDK finishes a project it gets de-staffed and they don't go back to it).




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: