def METHOD_NAME(*original_values):
    # Begin Truffle change
    # GraalPy adds sleeps in various places (e.g. 'gc_collect') to give our GC
    # more time for garbage collection such that each iteration is two orders of
    # magnitude slower than on CPython. We therefore reduce to 10 retries since
    # it seems that most tests reached a fixed point after 2 iterations.
    # original: _MAX_COUNT = 100
    _MAX_COUNT = 10
    # End Truffle change
    for count in range(_MAX_COUNT):
        values = _thread._count(), threading._dangling
        if values == original_values:
            break
        if not count:
            # Display a warning at the first iteration
            support.environment_altered = True
            dangling_threads = values[1]
            support.print_warning(f"threading_cleanup() failed to cleanup "
                                  f"{values[0] - original_values[0]} threads "
                                  f"(count: {values[0]}, "
                                  f"dangling: {len(dangling_threads)})")
            for thread in dangling_threads:
                support.print_warning(f"Dangling thread: {thread!r}")
            # Don't hold references to threads
            dangling_threads = None
        values = None
        time.sleep(0.01)
        support.gc_collect()