vavr-io / vavr

vʌvr (formerly called Javaslang) is a non-commercial, non-profit object-functional library that runs with Java 8+. It aims to reduce the lines of code and increase code quality.
https://vavr.io
Other
5.59k stars 620 forks source link

Avoid synchronized block or methods #2760

Open reda-alaoui opened 5 months ago

reda-alaoui commented 5 months ago

According to https://docs.oracle.com/en/java/javase/21/core/virtual-threads.html#GUID-04C03FFC-066D-4857-85B9-E5A27A875AF9:

A current limitation of the implementation of virtual threads is that performing a blocking operation while inside a synchronized block or method causes the JDK's virtual thread scheduler to block a precious OS thread, whereas it wouldn't if the blocking operation were done outside of a synchronized block or method. We call that situation "pinning".

IMHO, all synchronizd blocks or methods should be replaced with ReentrantLock usage.

He-Pin commented 5 months ago

Not all, only io bound I think.