static DetectThreadLeak of(Predicate<Thread> predicate) {
        Set<Long> before = Thread.getAllStackTraces().keySet()
                .stream().filter(predicate).map(Thread::getId).collect(Collectors.toSet());
        return () -> Thread.getAllStackTraces().keySet()
                .stream().filter(predicate)
                .filter(t -> !before.contains(t.getId()))
                .collect(Collectors.toList());
    }
Creates an instance of {@link DetectThreadLeak} that filters threads based on a given predicate.
This method captures the current state of threads that match the predicate at the time of invocation
and provides a way to detect new threads that match the predicate but were not present at the initial capture.

@param predicate A {@link Predicate<Thread>} used to filter threads. Only threads that satisfy
                 the predicate are considered for detection.
@return An instance of {@link DetectThreadLeak} that can be used to detect new threads matching
        the predicate that were not present at the time of this method's invocation.
        The {@link DetectThreadLeak#newThreads()} method of the returned instance will return a list
        of new threads that match the predicate and have been started after this method was called.
core/src/test/java/kafka/test/junit/DetectThreadLeak.java