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

AQS and lock classes refresh

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P2
    • Resolution: Approved
    • Fix Version/s: 14
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Hide
      The only conceivable compatibility risk of introducing the method is
      that because LockSupport is not a final class, some subclass could have
      a conflicting method. The likelihood is ignorably remote.
      Show
      The only conceivable compatibility risk of introducing the method is that because LockSupport is not a final class, some subclass could have a conflicting method. The likelihood is ignorably remote.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Method LockSupport.setCurrentBlocker was added as part of JDK-8229442 mainly to allow implementations to maintain compatibility with tools and utilities reporting LockSupport.getBlocker when threads are parked.

      Problem

      The primary rationale for this method is to allow people to improve compatibility with previous implementations that includes calls to LockSupport.park, with respect to tools expecting a particular type of blocker object to be reported in stack traces etc.

      Solution

      LockSupport.setCurrentBlocker allows a given blocker to be set instead of per-park arguments for upcoming calls to park that may be performed in some other object.

      Specification

      /**
       * Sets the object to be returned by invocations of {@link
       * #getBlocker getBlocker} for the current thread. This method may
       * be used before invoking the no-argument version of {@link
       * LockSupport#park() park()} from non-public objects, allowing
       * more helpful diagnostics, or retaining compatibility with
       * previous implementations of blocking methods.  Previous values
       * of the blocker are not automatically restored after blocking.
       * To obtain the effects of {@code park(b}}, use {@code
       * setCurrentBlocker(b); park(); setCurrentBlocker(null);}
       *
       * @param blocker the blocker object
       * @since 14
       */
      public static void setCurrentBlocker(Object blocker) {
          U.putObjectOpaque(Thread.currentThread(), PARKBLOCKER, blocker);
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dl Doug Lea
              Reporter:
              martin Martin Buchholz
              Reviewed By:
              David Holmes, Martin Buchholz
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: