Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid synchronized block or methods #2760

Open
reda-alaoui opened this issue Jan 31, 2024 · 1 comment
Open

Avoid synchronized block or methods #2760

reda-alaoui opened this issue Jan 31, 2024 · 1 comment

Comments

@reda-alaoui
Copy link

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
Copy link

He-Pin commented Jan 31, 2024

Not all, only io bound I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants