No video

Java's Virtual Threads - Next Steps

  Рет қаралды 14,967

Java

Java

6 ай бұрын

Virtual Threads graduated to a permanent feature in JDK 21 with huge interest and uptake in the Java ecosystem. There’s a lot more to do! This session will go through the current efforts on Java monitors, I/O, and other areas that will improve this feature in future JDK releases.
Presented by Alan Bateman (Oracle)
Recorded during FOSDEM 2024
◦ JEP 444: Virtual Threads ➱ openjdk.org/je...
◦ JEP 453: Structured Concurrency (Preview) ➱ openjdk.org/je...
◦ JEP 446: Scoped Values (Preview) ➱ openjdk.org/je...
◦ Repo ➱ github.com/ope...
◦ Mailing list ➱ mail.openjdk.o...
◦ FOSDEM 2024 Free Java Devroom ➱ fosdem.org/202...
Tags: #Java #OpenJDK #Concurrency #ProjectLoom

Пікірлер: 18
@user-pi9cj2or5n
@user-pi9cj2or5n 5 ай бұрын
Greatest async solution on the market
@qingtianwang3511
@qingtianwang3511 5 ай бұрын
Good knowledge source, but I don't follow what the speaker said in the end about "many issues" related to "synchronized" and monitors in JVM. If that is a big issue in JVM, then why not just use "javac" to convert all "synchronized" into "java.util.locks.Lock", making it a non-JVM issue in the first place? it'd be the same idea as "lombok" (hopefully not violating any of "them rules in the spec"). this could either be a Project Loom or Project Layden's job, but either way... Also, shouldn't it be a Project Loom job to deprecate the "synchronized" keyword if it's given more troubles than it brings benefits? same goes with those monitor methods on Object - wait/notify/notifyAll/... why are those concurrency concerns for the "Object" (instead of some other dedicated construct) to handle in the first place, and, if they are such a big problem, why not deprecate?
5 ай бұрын
So many problems in production code just for a little "syncronized". This reserved word should be behind bars the rest of its misserable life. I was thinking about the same, why do not "transpile" to locks...
@qingtianwang3511
@qingtianwang3511 5 ай бұрын
@@nisonatic but it goes without saying that, if we let "javac" to do this, the same "javac" will have to fail-fast at compile time if any lib/dependency is still on the "synchronized" keyword. and yes, somehow the newly built JAR will have to cause any old javac to fail-fast, signaling the old javac it's using some wrong/too-new class version or something...
@ImaginaryNumb3r
@ImaginaryNumb3r 5 ай бұрын
This only works for code directly under your control. If you are using libraries which are using synchronized, you can't do this trick. Source compatibility != Binary Compatibility
@qingtianwang3511
@qingtianwang3511 5 ай бұрын
@@ImaginaryNumb3r again, in that case, javac will have to fail-fast, telling me to go some other route. It doesn't have to work with old code, at all, as long as it reliably says what works and what doesn't.
@dansadventures5514
@dansadventures5514 2 ай бұрын
Project Loom / virtual threads was released a year too soon. Many projects are encountering deadlocks due to pinning. I thought that the 6-month release train doesn't try to squeeze in unfinished features so I'm not sure why they felt the need to rush with this one.
@tarphuer
@tarphuer 5 ай бұрын
question: whats the drawback of modifying the compiler to replace synchronize blocks with Lock to temporarily work around the issue?
@cptmorgan92
@cptmorgan92 5 ай бұрын
I think The drawback are the existing PlatformThreads and that you couldn’t guarantee that legacy code still work as expected. Before solving this problem it would be necessary to replace the PlatformThreads with VirtualThreads.
@prdoyle
@prdoyle 5 ай бұрын
An object's own monitor is part of its public interface. Anyone, at any time, could lock on any object's monitor. You can't, in general, substitute a different lock.
@qingtianwang3511
@qingtianwang3511 5 ай бұрын
@@prdoyle couldn't those monitor methods on Object also be auto converted by "javac" to something better?
@AliakseyKandratsenka
@AliakseyKandratsenka 5 ай бұрын
​@@qingtianwang3511Complication is how do you find that associated lock? Inside more or less this is what happens. There is a ton of interesting hackery to make it efficient in memory and cycles. But doing this at byte code level is likely to be a lot less cheap. I.e. some sort global hash map from object's identity hash to the lock? Imagine how slow it'll be.
@MatthewLeidholm
@MatthewLeidholm 5 ай бұрын
In addition to reducing the situations in which virtual threads get unnecessarily pinned, it would be nice if the library folks would work on reducing the number of API calls that do unnecessary synchronization. It's all well and good if you have asynchronous I/O behind the scenes, but if it passes through a BufferedReader, that's going to pin the virtual thread, whether you're accessing it from multiple threads or not.
@alanbateman9657
@alanbateman9657 5 ай бұрын
BufferedReader was updated in JDK 19 to a j.u.concurrent lock where possible.
@cptmorgan92
@cptmorgan92 5 ай бұрын
Oh is synchronized still a problem with loom? I wrote a visualizer for monitors in 2022 and run into this issue for the next release
@nilskp
@nilskp 5 ай бұрын
What problem/issue are you referring to?
@javaumesh
@javaumesh 5 ай бұрын
wow superb
@csm2526
@csm2526 5 ай бұрын
It seems java21 is a bit slower compared to java17
Finger Heart - Fancy Refill (Inside Out Animation)
00:30
FASH
Рет қаралды 32 МЛН
Каха заблудился в горах
00:57
К-Media
Рет қаралды 11 МЛН
Java 21 new feature: Virtual Threads #RoadTo21
33:35
Java
Рет қаралды 60 М.
How Netflix Really Uses Java
50:31
InfoQ
Рет қаралды 48 М.
Java Language Update - Early 2024 Edition
51:36
Java
Рет қаралды 15 М.
What's Looming in Spring? by VENKAT SUBRAMANIAM & JOSH LONG
52:26
Spring Tips: Virtual Threads
50:31
SpringDeveloper
Рет қаралды 12 М.
Project Leyden: Capturing Lightning in a Bottle
45:50
Java 21… and Beyond
48:30
Java
Рет қаралды 23 М.
Finger Heart - Fancy Refill (Inside Out Animation)
00:30
FASH
Рет қаралды 32 МЛН