public static Collection < Thread > findThreadsByName ( final String threadName , final String threadGroupName ) { Validate . isTrue ( threadName != null , "The thread name must not be null" ) ; Validate . isTrue ( threadGroupName != null , "The thread group name must not be null" ) ; final Collection < ThreadGroup > threadGroups = findThreadGroups ( new NamePredicate ( threadGroupName ) ) ; if ( threadGroups . isEmpty ( ) ) { return Collections . emptyList ( ) ; } final Collection < Thread > result = new ArrayList <> ( ) ; final NamePredicate threadNamePredicate = new NamePredicate ( threadName ) ; for ( final ThreadGroup group : threadGroups ) { result . addAll ( findThreads ( group , false , threadNamePredicate ) ) ; } return Collections . unmodifiableCollection ( result ) ; }
Return active threads with the specified name if they belong to a thread group with the specified group name .