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

Clarify thread interrupts during initialization

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 8
    • specification
    • None
    • vm
    • generic
    • generic
    • Verified

      JVMS7 5.5 says: "If the Class object for C indicates that initialization is in progress for C by some other thread, then release LC and block the current thread until informed that the in-progress initialization has completed, at which time repeat this procedure."

      It has been observed that if the blocked thread is interrupted by some other code, then some JVM implementations may clear the (formerly-)blocked thread's interrupt status and swallow the InterruptedException otherwise intended for the (formerly-)blocked thread. Eventually, the other thread's class initialization will complete and the (formerly-)blocked thread will proceed, but because it has "lost" its interrupted status, a subsequent wait() in its own code will wait forever.

      The thinking behind the text in JVMS7 is that to "block the current thread" is not specified as equivalent to invoking wait() on it, so blocking is not defined to be interruptible, so blocking is orthogonal to any interrupted status that a thread might have before attempting initialization.

      However, for clarity, it is desirable to add a frame condition to 5.5: "Thread interrupt status is unaffected by execution of the class initialization procedure."

            abuckley Alex Buckley
            abuckley Alex Buckley
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: