Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-6035

[drlvm] ThreadGroup does not destory dead Thread and ThreadGroup correctly

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.0M8
    • Fix Version/s: 5.0M9
    • Component/s: DRLVM
    • Labels:
      None

      Description

      Conduct a test case [1] on RI and HARMONY.
      RI works well while HARMONY fails on both of them.
      As to the 1st test, HARMONY uses "equals" method during destroying while RI doesn't.
      I think this may be the root cause for the second test.

      [1]
      public void test_destroy_OverrideEquals() {
      class MockThreadGroup extends ThreadGroup {

      private boolean isCalled = false;

      public void reset()

      { isCalled = false; }

      public boolean isCallEqauls()

      { return isCalled; }

      public MockThreadGroup(String name)

      { super(name); reset(); }

      public MockThreadGroup(ThreadGroup parent, String name)

      { super(parent, name); reset(); }

      public boolean equals(Object obj)

      { isCalled = true; return false; }

      }

      MockThreadGroup ptg = new MockThreadGroup("Parent");
      MockThreadGroup ctg = new MockThreadGroup(ptg, "Child");
      MockThreadGroup dtg = new MockThreadGroup(ptg, "Daemon");
      dtg.setDaemon(true);
      assertEquals(2, ptg.activeGroupCount());
      ptg.destroy();
      assertFalse(ptg.isCallEqauls());
      assertFalse(ctg.isCallEqauls());
      assertFalse(dtg.isCallEqauls());
      assertEquals(0, ptg.activeGroupCount());
      }

      public void test_setDaemonZ_Destory() throws InterruptedException {
      ThreadGroup daemonGroup = new ThreadGroup("daemon");
      Thread myThread = new Thread(daemonGroup, new Runnable() {
      public void run() {
      }
      });
      ThreadGroup childGroup = new ThreadGroup(daemonGroup, "child");
      daemonGroup.setDaemon(true);

      assertEquals(0, daemonGroup.activeCount());
      childGroup.destroy();
      assertTrue(childGroup.isDestroyed());
      assertFalse(daemonGroup.isDestroyed());

      myThread.start();
      myThread.join();
      assertTrue(daemonGroup.isDestroyed());
      }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              zhoukevin Kevin Zhou
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: