Comment

Comment by cesarb

It's not news only if you carefully read that JEP (and even then, it's misleading, it says "Pinning does not make an application incorrect, but it might hinder its scalability" as if using "synchronized" could only lead to not getting the full performance advantage of virtual threads; there's no mention of potential thread starvation or deadlocks). But most people are not reading JEP pages; most people are getting their information from release notes and news articles, and AFAIK these didn't mention the important caveat that virtual threads can misbehave if anything waits within a synchronized block (which is very common, synchronized blocks and methods exist and are widely used since the early days of Java).

For instance, a quick web search led me to a release notes page (https://www.oracle.com/java/technologies/javase/21-relnote-i...) and a news article (https://www.infoworld.com/article/3689880/jdk-21-the-new-fea...), neither mention anything about synchronized blocks and methods. In fact, the later one says "Previously previewed in both JDK 20 and JDK 19, virtual threads will be finalized in JDK 21.", as if everything now works as expected with virtual threads on Java 21. Which is clearly not the case, if synchronized blocks are enough to make it misbehave. IMO, we can only say virtual threads are really "finalized" once synchronized blocks work as expected (releasing the carrier thread, like AFAIK ReentrantLock already does) when running on a virtual thread.

parent cesarb 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton