4 ms·
> How would it break any code? You have to explicitly use virtual threads, normal threads are not touched at all and will work as they have always did. You oft
by cesarb 2y ago
> How would it break any code? You have to explicitly use virtual threads, normal threads are not touched at all and will work as they have always did.
You often have no control over what kind of thread the caller of your code is using. Code written for the old threading model can and will end up being called by these newfangled virtual threads. If it does something the virtual threads don't like (which, as far as I have heard, includes things like some uses of synchronized blocks), you can have unexpected breakage.
- imtringued 2y agoYou're confusing the thread pinning problem with "breakage". The problem with some synchronized blocks is that they lead to thread pinning for the duration of the lock. Why is thread pinning bad? Because it means that if one core is idle, but all the threads are pinned to a specific core, you won't get full CPU utilisation. This undermines the performance benefit of virtual threads, because they are supposed to be schedulable via work stealing.
- kaba0 2y agoThat’s not backwards compatibility, but forwards compatibility, though. And you would really have to go out of your way to introduce such an issue. Certain extreme (e.g. native calls) cases are handled by simply pinning a virtual thread to a real thread. So it would only cause an issue if it was already causing an issue at much smaller thread numbers. And many of these extreme cases are getting “solved” to not pin the thread.