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

Replace synchronized with ReentrantLock #95

Closed
wants to merge 1 commit into from

Commits on Mar 24, 2023

  1. Replace synchronized with ReentrantLock

    Replace connectionMutex and synchronized blocks with a ReentrantLock. The synchronized blocks were removed and replaced by `lock.lock()` and `lock.unlock()`. This avoids that the carrier thread (OS thread) is pinned when running on virtual threads which were introduced as a preview feature in JDK 19.
    
    The JEP that is being prepared for JDK 21:
    https://openjdk.org/jeps/8303683
    
    `There are two scenarios in which a virtual thread cannot be unmounted during blocking operations because it is pinned to its carrier:
    
     When it executes code inside a synchronized block or method, or
     When it executes a native method or a foreign function.`
    bdeneuter committed Mar 24, 2023
    Configuration menu
    Copy the full SHA
    8188786 View commit details
    Browse the repository at this point in the history