On Wed, 14 Jun 2023 09:30:49 GMT, Kevin Walls <kev...@openjdk.org> wrote:
> This test fails when additional threads are created, as it compares thread > lists from different sources and sees a mismatch. > > It needs to tolerate some threads with certain names appearing, e.g. JVMCI > and ForkJoin threads. If there are extra threads in the thread ID list from > the ThreadMBean, remove them from the thread count before comparing. > > When it fails, additionally print the ids and names of threads that it got > from the MBean. > > I found the test quite confusing, the naming of thread counts, arrays of > threads, and arrays of thread stacktraces from different sources, so have > renamed some things. I agree with David and would be concerned this test will be whack-a-mole to deal with other cases. It would be a lot simpler to have a test that creates a number of threads, then uses Thread.getAllThreadStacks + ThreadMXBean.getAllThreadIds to that the expected list of threads are included. If the current thread is not a virtual thread then it can check that it is included too. If you really want to check that both methods return the same list of threads then I think it will need to loop + backoff when the threads aren't the same. ------------- PR Comment: https://git.openjdk.org/jdk/pull/14465#issuecomment-1592424397