Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8281642

Thread.holdsLock returns true on a virtual thread when monitor is owned by the carrier

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 19, repo-loom
    • hotspot

      Currently, virtual threads are never mounted on the scheduler's carriers (FJPool workers) with a monitor held, but custom schedulers could do that.

      While ObjectSynchronizer::current_thread_holds_lock (which implements Thread.holdsLock) could easily check whether it is the vthread or its carrier holding the lock in the stack-lock case, using JavaThread::is_lock_owned_current instead of JavaThread::is_lock_owned, that is not the case when monitor->is_entered is called, where the monitor's owner might be the JavaThread itself.

            pchilanomate Patricio Chilano Mateo
            rpressler Ron Pressler
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: