harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Zhou (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-6035) [classlib][luni-kernel] ThreadGroup does not destory dead Thread and ThreadGroup correctly
Date Fri, 05 Dec 2008 04:52:44 GMT
[classlib][luni-kernel] ThreadGroup does not destory dead Thread and ThreadGroup correctly
------------------------------------------------------------------------------------------

                 Key: HARMONY-6035
                 URL: https://issues.apache.org/jira/browse/HARMONY-6035
             Project: Harmony
          Issue Type: Bug
          Components: DRLVM
    Affects Versions: 5.0M8
            Reporter: Kevin Zhou
             Fix For: 5.0M9


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());
    }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message