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

New Thread cannot park when reusing an earlier Thread's Parker whose _counter is not zero

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • openjdk8u292, 11.0.11
    • hotspot
    • generic
    • generic

      Submit on hehalf of miao zheng.

      In attached test Parker.java, two threads are created, second thread is created after first thread join and finish.

      In jdk18, the second thread is parked. In jdk8 and jdk11, the second thread is not parked, it will just go ahead and print the log "^^^^^^: testPark12 running here".

      Behavior should be same for jdk8/11 and lasted jdk18.

      The problem is in jdk8/11 Parker::Allocate and Parker::Release. There is a free list of parker, and when the first thread exit, it releases the parker to the free list. Before the parker release to the free list, the _counter of Parker should be reset.

      In jdk18, https://bugs.openjdk.java.net/browse/JDK-8223056 removes the free list of parker, and each thread has its own parker, so this problem is solved.

      Not sure backport entier https://bugs.openjdk.java.net/browse/JDK-8223056. Or keep parker freelist mechanism, only reset _counter when release.

            hshi Hui Shi
            hshi Hui Shi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: