Increase Java 21 virtual thread performance via get rid of synchronized #2032
Labels
api: pubsub
Issues related to the googleapis/java-pubsub API.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
What the problem is : Java 21 virtual thread might hinder its scalability when using synchronized
Based on Java doc Java 21 virtual thread
A virtual thread cannot be unmounted during blocking operations when it is pinned to its carrier. A virtual thread is pinned in the following situations:
Pinning does not make an application incorrect, but it might hinder its scalability.
Try avoiding frequent and long-lived pinning by revising synchronized blocks or methods that run frequently and guarding potentially long I/O operations with java.util.concurrent.locks.ReentrantLock.
Describe the solution you'd like
Use java.util.concurrent.locks.ReentrantLock instead of synchronized
The text was updated successfully, but these errors were encountered: