Top Description Inners Fields Constructors Methods
org.apache.commons.lang3

public Class ThreadUtils

extends Object
Class Inheritance
Imports
java.time.Duration, java.util.Collection, .Collections, .Objects, java.util.function.Function, .Predicate, java.util.stream.Collectors, .Stream, org.apache.commons.lang3.function.Predicates, org.apache.commons.lang3.time.DurationUtils

Helpers for Thread and ThreadGroup.

#ThreadSafe#

Since
3.5
See Also
Thread, ThreadGroup

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ThreadUtils.AlwaysTruePredicate

Deprecated Use a Predicate.
A predicate implementation which always returns true.
public static class
ThreadUtils.NamePredicate

Deprecated Use a Predicate.
Used internally, consider private.
public static interface
ThreadUtils.ThreadGroupPredicate

Deprecated Use a Predicate.
A predicate for selecting thread groups.
public static class
ThreadUtils.ThreadIdPredicate

Deprecated Use a Predicate.
A predicate implementation which matches a thread id.
public static interface
ThreadUtils.ThreadPredicate

Deprecated Use a Predicate.
A predicate for selecting threads.

Field Summary

Modifier and TypeField and Description
public static final ThreadUtils.AlwaysTruePredicate
ALWAYS_TRUE_PREDICATE

Deprecated Use a Predicate.
Predicate which always returns true.

Constructor Summary

AccessConstructor and Description
public
ThreadUtils()
Deprecated TODO Make private in 4.0.

ThreadUtils instances should NOT be constructed in standard programming.

Method Summary

Modifier and TypeMethod and Description
public static Thread

Returns:

The thread with the specified id or null if no such thread exists.
findThreadById
(final long
The thread id.
threadId
)

Finds the active thread with the specified id.

public static Thread

Returns:

The threads which belongs to a thread group with the specified group name and the thread's id match the specified id. null is returned if no such thread exists.
findThreadById
(final long
The thread id.
threadId
,
final String
The thread group name.
threadGroupName
)

Finds the active thread with the specified id if it belongs to a thread group with the specified group name.

public static Thread

Returns:

The thread which belongs to a specified thread group and the thread's id match the specified id. null is returned if no such thread exists.
findThreadById
(final long
The thread id.
threadId
,
final ThreadGroup
The thread group.
threadGroup
)

Finds the active thread with the specified id if it belongs to the specified thread group.

public static Collection<ThreadGroup>

Returns:

An unmodifiable Collection of active thread groups matching the given predicate.
findThreadGroups
(final Predicate<ThreadGroup>
the predicate.
predicate
)

Finds all active thread groups which match the given predicate.

public static Collection<ThreadGroup>

Returns:

An unmodifiable Collection of active thread groups which match the given predicate and which is a subgroup of the given thread group.
findThreadGroups
(final ThreadGroup
the thread group.
threadGroup
,
final boolean
if true then evaluate the predicate recursively on all thread groups in all subgroups of the given group.
recurse
,
final Predicate<ThreadGroup>
the predicate.
predicate
)

Finds all active thread groups which match the given predicate and which is a subgroup of the given thread group (or one of its subgroups).

public static Collection<ThreadGroup>

Returns:

An unmodifiable Collection of active thread groups which match the given predicate and which is a subgroup of the given thread group.
findThreadGroups
(final ThreadGroup
the thread group.
threadGroup
,
final boolean
if true then evaluate the predicate recursively on all thread groups in all subgroups of the given group.
recurse
,
final ThreadUtils.ThreadGroupPredicate
the predicate.
predicate
)

Finds all active thread groups which match the given predicate and which is a subgroup of the given thread group (or one of its subgroups).

public static Collection<ThreadGroup>

Returns:

An unmodifiable Collection of active thread groups matching the given predicate.
findThreadGroups
(final ThreadUtils.ThreadGroupPredicate
the predicate.
predicate
)
Deprecated Use findThreadGroups(Predicate).

Finds all active thread groups which match the given predicate.

public static Collection<ThreadGroup>

Returns:

the thread groups with the specified group name or an empty collection if no such thread group exists. The collection returned is always unmodifiable.
findThreadGroupsByName
(final String
The thread group name.
threadGroupName
)

Finds active thread groups with the specified group name.

public static Collection<Thread>

Returns:

An unmodifiable Collection of active threads matching the given predicate.
findThreads
(final Predicate<Thread>
the predicate.
predicate
)

Finds all active threads which match the given predicate.

public static Collection<Thread>

Returns:

An unmodifiable Collection of active threads which match the given predicate and which belongs to the given thread group.
findThreads
(final ThreadGroup
the thread group.
threadGroup
,
final boolean
if true then evaluate the predicate recursively on all threads in all subgroups of the given group.
recurse
,
final Predicate<Thread>
the predicate.
predicate
)

Finds all active threads which match the given predicate and which belongs to the given thread group (or one of its subgroups).

public static Collection<Thread>

Returns:

An unmodifiable Collection of active threads which match the given predicate and which belongs to the given thread group.
findThreads
(final ThreadGroup
the thread group.
threadGroup
,
final boolean
if true then evaluate the predicate recursively on all threads in all subgroups of the given group.
recurse
,
final ThreadUtils.ThreadPredicate
the predicate.
predicate
)

Finds all active threads which match the given predicate and which belongs to the given thread group (or one of its subgroups).

public static Collection<Thread>

Returns:

An unmodifiable Collection of active threads matching the given predicate.
findThreads
(final ThreadUtils.ThreadPredicate
the predicate.
predicate
)
Deprecated Use findThreads(Predicate).

Finds all active threads which match the given predicate.

public static Collection<Thread>

Returns:

The threads with the specified name or an empty collection if no such thread exists. The collection returned is always unmodifiable.
findThreadsByName
(final String
The thread name.
threadName
)

Finds active threads with the specified name.

public static Collection<Thread>

Returns:

The threads which belongs to a thread group with the specified group name and the thread's name match the specified name, An empty collection is returned if no such thread exists. The collection returned is always unmodifiable.
findThreadsByName
(final String
The thread name.
threadName
,
final String
The thread group name.
threadGroupName
)

Finds active threads with the specified name if they belong to a thread group with the specified group name.

public static Collection<Thread>

Returns:

The threads which belongs to a thread group and the thread's name match the specified name, An empty collection is returned if no such thread exists. The collection returned is always unmodifiable.
findThreadsByName
(final String
The thread name.
threadName
,
final ThreadGroup
The thread group.
threadGroup
)

Finds active threads with the specified name if they belong to a specified thread group.

public static Collection<ThreadGroup>

Returns:

all thread groups excluding the system thread group. The collection returned is always unmodifiable.
getAllThreadGroups
()

Gets all active thread groups excluding the system thread group (A thread group is active if it has been not destroyed).

public static Collection<Thread>

Returns:

all active threads. The collection returned is always unmodifiable.
getAllThreads
()

Gets all active threads (A thread is active if it has been started and has not yet died).

public static ThreadGroup

Returns:

the system thread group.
getSystemThreadGroup
()

Gets the system thread group (sometimes also referred as "root thread group").

public static void
join(final Thread
The thread to join.
thread
,
final Duration
How long to wait.
duration
)

Waits for the given thread to die for the given duration.

private static <T> Predicate<T>
namePredicate(final String name, final Function<T, String> nameGetter)

private static Predicate<Thread>
predicateThread(final String threadName)

private static Predicate<ThreadGroup>
predicateThreadGroup(final String threadGroupName)

public static void
sleep(final Duration
How long to sleep.
duration
)

Sleeps the current thread for the given duration.

public static void
sleepQuietly(final Duration
the length of time to sleep.
duration
)

Sleeps for the given duration while ignoring InterruptedException.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALWAYS_TRUE_PREDICATEback to summary
public static final ThreadUtils.AlwaysTruePredicate ALWAYS_TRUE_PREDICATE

Deprecated

Use a Predicate.

Predicate which always returns true.

Annotations
@Deprecated

Constructor Detail

ThreadUtilsback to summary
public ThreadUtils()

Deprecated

TODO Make private in 4.0.

ThreadUtils instances should NOT be constructed in standard programming. Instead, the class should be used as ThreadUtils.getAllThreads()

This constructor is public to permit tools that require a JavaBean instance to operate.

Annotations
@Deprecated

Method Detail

findThreadByIdback to summary
public static Thread findThreadById(final long threadId)

Finds the active thread with the specified id.

Parameters
threadId:long

The thread id.

Returns:Thread

The thread with the specified id or null if no such thread exists.

Exceptions
IllegalArgumentException:
if the specified id is zero or negative.
SecurityException:
  • if the current thread cannot access the system thread group.
  • if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
findThreadByIdback to summary
public static Thread findThreadById(final long threadId, final String threadGroupName)

Finds the active thread with the specified id if it belongs to a thread group with the specified group name.

Parameters
threadId:long

The thread id.

threadGroupName:String

The thread group name.

Returns:Thread

The threads which belongs to a thread group with the specified group name and the thread's id match the specified id. null is returned if no such thread exists.

Exceptions
NullPointerException:
if the group name is null.
IllegalArgumentException:
if the specified id is zero or negative.
SecurityException:
  • if the current thread cannot access the system thread group.
  • if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
findThreadByIdback to summary
public static Thread findThreadById(final long threadId, final ThreadGroup threadGroup)

Finds the active thread with the specified id if it belongs to the specified thread group.

Parameters
threadId:long

The thread id.

threadGroup:ThreadGroup

The thread group.

Returns:Thread

The thread which belongs to a specified thread group and the thread's id match the specified id. null is returned if no such thread exists.

Exceptions
NullPointerException:
if threadGroup == null.
IllegalArgumentException:
if the specified id is zero or negative.
SecurityException:
  • if the current thread cannot access the system thread group.
  • if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
findThreadGroupsback to summary
public static Collection<ThreadGroup> findThreadGroups(final Predicate<ThreadGroup> predicate)

Finds all active thread groups which match the given predicate.

Parameters
predicate:Predicate<ThreadGroup>

the predicate.

Returns:Collection<ThreadGroup>

An unmodifiable Collection of active thread groups matching the given predicate.

Exceptions
NullPointerException:
if the predicate is null.
SecurityException:
  • if the current thread cannot access the system thread group.
  • if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
Since
3.13.0
findThreadGroupsback to summary
public static Collection<ThreadGroup> findThreadGroups(final ThreadGroup threadGroup, final boolean recurse, final Predicate<ThreadGroup> predicate)

Finds all active thread groups which match the given predicate and which is a subgroup of the given thread group (or one of its subgroups).

Parameters
threadGroup:ThreadGroup

the thread group.

recurse:boolean

if true then evaluate the predicate recursively on all thread groups in all subgroups of the given group.

predicate:Predicate<ThreadGroup>

the predicate.

Returns:Collection<ThreadGroup>

An unmodifiable Collection of active thread groups which match the given predicate and which is a subgroup of the given thread group.

Exceptions
NullPointerException:
if the given group or predicate is null.
SecurityException:
if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
Since
3.13.0
findThreadGroupsback to summary
public static Collection<ThreadGroup> findThreadGroups(final ThreadGroup threadGroup, final boolean recurse, final ThreadUtils.ThreadGroupPredicate predicate)

Finds all active thread groups which match the given predicate and which is a subgroup of the given thread group (or one of its subgroups).

Parameters
threadGroup:ThreadGroup

the thread group.

recurse:boolean

if true then evaluate the predicate recursively on all thread groups in all subgroups of the given group.

predicate:ThreadUtils.ThreadGroupPredicate

the predicate.

Returns:Collection<ThreadGroup>

An unmodifiable Collection of active thread groups which match the given predicate and which is a subgroup of the given thread group.

Annotations
@Deprecated
Exceptions
NullPointerException:
if the given group or predicate is null.
SecurityException:
if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
findThreadGroupsback to summary
public static Collection<ThreadGroup> findThreadGroups(final ThreadUtils.ThreadGroupPredicate predicate)

Finds all active thread groups which match the given predicate.

Parameters
predicate:ThreadUtils.ThreadGroupPredicate

the predicate.

Returns:Collection<ThreadGroup>

An unmodifiable Collection of active thread groups matching the given predicate.

Annotations
@Deprecated
Exceptions
NullPointerException:
if the predicate is null.
SecurityException:
  • if the current thread cannot access the system thread group.
  • if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
findThreadGroupsByNameback to summary
public static Collection<ThreadGroup> findThreadGroupsByName(final String threadGroupName)

Finds active thread groups with the specified group name.

Parameters
threadGroupName:String

The thread group name.

Returns:Collection<ThreadGroup>

the thread groups with the specified group name or an empty collection if no such thread group exists. The collection returned is always unmodifiable.

Exceptions
NullPointerException:
if group name is null.
SecurityException:
  • if the current thread cannot access the system thread group.
  • if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
findThreadsback to summary
public static Collection<Thread> findThreads(final Predicate<Thread> predicate)

Finds all active threads which match the given predicate.

Parameters
predicate:Predicate<Thread>

the predicate.

Returns:Collection<Thread>

An unmodifiable Collection of active threads matching the given predicate.

Exceptions
NullPointerException:
if the predicate is null.
SecurityException:
  • if the current thread cannot access the system thread group.
  • if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
Since
3.13.0
findThreadsback to summary
public static Collection<Thread> findThreads(final ThreadGroup threadGroup, final boolean recurse, final Predicate<Thread> predicate)

Finds all active threads which match the given predicate and which belongs to the given thread group (or one of its subgroups).

Parameters
threadGroup:ThreadGroup

the thread group.

recurse:boolean

if true then evaluate the predicate recursively on all threads in all subgroups of the given group.

predicate:Predicate<Thread>

the predicate.

Returns:Collection<Thread>

An unmodifiable Collection of active threads which match the given predicate and which belongs to the given thread group.

Exceptions
NullPointerException:
if the given group or predicate is null.
SecurityException:
if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
Since
3.13.0
findThreadsback to summary
public static Collection<Thread> findThreads(final ThreadGroup threadGroup, final boolean recurse, final ThreadUtils.ThreadPredicate predicate)

Finds all active threads which match the given predicate and which belongs to the given thread group (or one of its subgroups).

Parameters
threadGroup:ThreadGroup

the thread group.

recurse:boolean

if true then evaluate the predicate recursively on all threads in all subgroups of the given group.

predicate:ThreadUtils.ThreadPredicate

the predicate.

Returns:Collection<Thread>

An unmodifiable Collection of active threads which match the given predicate and which belongs to the given thread group.

Annotations
@Deprecated
Exceptions
NullPointerException:
if the given group or predicate is null.
SecurityException:
if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
findThreadsback to summary
public static Collection<Thread> findThreads(final ThreadUtils.ThreadPredicate predicate)

Deprecated

Use findThreads(Predicate).

Finds all active threads which match the given predicate.

Parameters
predicate:ThreadUtils.ThreadPredicate

the predicate.

Returns:Collection<Thread>

An unmodifiable Collection of active threads matching the given predicate.

Annotations
@Deprecated
Exceptions
NullPointerException:
if the predicate is null.
SecurityException:
  • if the current thread cannot access the system thread group.
  • if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
findThreadsByNameback to summary
public static Collection<Thread> findThreadsByName(final String threadName)

Finds active threads with the specified name.

Parameters
threadName:String

The thread name.

Returns:Collection<Thread>

The threads with the specified name or an empty collection if no such thread exists. The collection returned is always unmodifiable.

Exceptions
NullPointerException:
if the specified name is null.
SecurityException:
  • if the current thread cannot access the system thread group.
  • if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
findThreadsByNameback to summary
public static Collection<Thread> findThreadsByName(final String threadName, final String threadGroupName)

Finds active threads with the specified name if they belong to a thread group with the specified group name.

Parameters
threadName:String

The thread name.

threadGroupName:String

The thread group name.

Returns:Collection<Thread>

The threads which belongs to a thread group with the specified group name and the thread's name match the specified name, An empty collection is returned if no such thread exists. The collection returned is always unmodifiable.

Exceptions
NullPointerException:
if the specified thread name or group name is null.
SecurityException:
  • if the current thread cannot access the system thread group.
  • if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
findThreadsByNameback to summary
public static Collection<Thread> findThreadsByName(final String threadName, final ThreadGroup threadGroup)

Finds active threads with the specified name if they belong to a specified thread group.

Parameters
threadName:String

The thread name.

threadGroup:ThreadGroup

The thread group.

Returns:Collection<Thread>

The threads which belongs to a thread group and the thread's name match the specified name, An empty collection is returned if no such thread exists. The collection returned is always unmodifiable.

Exceptions
NullPointerException:
if the specified thread name or group is null.
SecurityException:
  • if the current thread cannot access the system thread group.
  • if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
getAllThreadGroupsback to summary
public static Collection<ThreadGroup> getAllThreadGroups()

Gets all active thread groups excluding the system thread group (A thread group is active if it has been not destroyed).

Returns:Collection<ThreadGroup>

all thread groups excluding the system thread group. The collection returned is always unmodifiable.

Exceptions
SecurityException:
  • if the current thread cannot access the system thread group.
  • if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
getAllThreadsback to summary
public static Collection<Thread> getAllThreads()

Gets all active threads (A thread is active if it has been started and has not yet died).

Returns:Collection<Thread>

all active threads. The collection returned is always unmodifiable.

Exceptions
SecurityException:
  • if the current thread cannot access the system thread group.
  • if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
getSystemThreadGroupback to summary
public static ThreadGroup getSystemThreadGroup()

Gets the system thread group (sometimes also referred as "root thread group").

This method returns null if this thread has died (been stopped).

Returns:ThreadGroup

the system thread group.

Exceptions
SecurityException:
if the current thread cannot modify thread groups from this thread's thread group up to the system thread group.
joinback to summary
public static void join(final Thread thread, final Duration duration) throws InterruptedException

Waits for the given thread to die for the given duration. Implemented using Thread#join(long, int).

Parameters
thread:Thread

The thread to join.

duration:Duration

How long to wait.

Exceptions
InterruptedException:
if any thread has interrupted the current thread.
Since
3.12.0
See Also
Thread#join(long, int)
namePredicateback to summary
private static <T> Predicate<T> namePredicate(final String name, final Function<T, String> nameGetter)
predicateThreadback to summary
private static Predicate<Thread> predicateThread(final String threadName)
predicateThreadGroupback to summary
private static Predicate<ThreadGroup> predicateThreadGroup(final String threadGroupName)
sleepback to summary
public static void sleep(final Duration duration) throws InterruptedException

Sleeps the current thread for the given duration. Implemented using Thread#sleep(long, int).

Parameters
duration:Duration

How long to sleep.

Exceptions
InterruptedException:
if any thread has interrupted the current thread.
Since
3.12.0
See Also
Thread#sleep(long, int)
sleepQuietlyback to summary
public static void sleepQuietly(final Duration duration)

Sleeps for the given duration while ignoring InterruptedException.

The sleep duration may be shorter than duration if we catch a InterruptedException.

Parameters
duration:Duration

the length of time to sleep.

Since
3.13.0
org.apache.commons.lang3 back to summary

private final Class ThreadUtils.AlwaysTruePredicate

extends Object
implements ThreadPredicate, ThreadGroupPredicate
Class Inheritance
All Implemented Interfaces
org.apache.commons.lang3.ThreadUtils.ThreadGroupPredicate, org.apache.commons.lang3.ThreadUtils.ThreadPredicate
Annotations
@Deprecated

Deprecated

Use a Predicate.

A predicate implementation which always returns true.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
test(final Thread thread)

Implements org.apache.commons.lang3.ThreadUtils.ThreadPredicate.test.

Evaluates this predicate on the given thread.

public boolean
test(final ThreadGroup threadGroup)

Implements org.apache.commons.lang3.ThreadUtils.ThreadGroupPredicate.test.

Evaluates this predicate on the given thread group.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AlwaysTruePredicateback to summary
private AlwaysTruePredicate()

Method Detail

testback to summary
public boolean test(final Thread thread)

Implements org.apache.commons.lang3.ThreadUtils.ThreadPredicate.test.

Doc from org.apache.commons.lang3.ThreadUtils.ThreadPredicate.test.

Evaluates this predicate on the given thread.

Annotations
@Override
testback to summary
public boolean test(final ThreadGroup threadGroup)

Implements org.apache.commons.lang3.ThreadUtils.ThreadGroupPredicate.test.

Doc from org.apache.commons.lang3.ThreadUtils.ThreadGroupPredicate.test.

Evaluates this predicate on the given thread group.

Annotations
@Override
org.apache.commons.lang3 back to summary

public Class ThreadUtils.NamePredicate

extends Object
implements ThreadPredicate, ThreadGroupPredicate
Class Inheritance
All Implemented Interfaces
org.apache.commons.lang3.ThreadUtils.ThreadGroupPredicate, org.apache.commons.lang3.ThreadUtils.ThreadPredicate
Annotations
@Deprecated

Deprecated

Use a Predicate.

Used internally, consider private.

A predicate implementation which matches a thread or thread group name.

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public
NamePredicate(final String
thread or thread group name.
name
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public boolean
test(final Thread thread)

Implements org.apache.commons.lang3.ThreadUtils.ThreadPredicate.test.

Evaluates this predicate on the given thread.

public boolean
test(final ThreadGroup threadGroup)

Implements org.apache.commons.lang3.ThreadUtils.ThreadGroupPredicate.test.

Evaluates this predicate on the given thread group.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nameback to summary
private final String name

Constructor Detail

NamePredicateback to summary
public NamePredicate(final String name)

Constructs an instance.

Parameters
name:String

thread or thread group name.

Exceptions
NullPointerException:
if the name is null.

Method Detail

testback to summary
public boolean test(final Thread thread)

Implements org.apache.commons.lang3.ThreadUtils.ThreadPredicate.test.

Doc from org.apache.commons.lang3.ThreadUtils.ThreadPredicate.test.

Evaluates this predicate on the given thread.

Annotations
@Override
testback to summary
public boolean test(final ThreadGroup threadGroup)

Implements org.apache.commons.lang3.ThreadUtils.ThreadGroupPredicate.test.

Doc from org.apache.commons.lang3.ThreadUtils.ThreadGroupPredicate.test.

Evaluates this predicate on the given thread group.

Annotations
@Override
org.apache.commons.lang3 back to summary

public Interface ThreadUtils.ThreadGroupPredicate

Known Direct Implementers
org.apache.commons.lang3.ThreadUtils.AlwaysTruePredicate, org.apache.commons.lang3.ThreadUtils.NamePredicate
Annotations
@Deprecated
@FunctionalInterface

Deprecated

Use a Predicate.

A predicate for selecting thread groups.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the threadGroup matches the predicate, otherwise false
test
(ThreadGroup
the thread group
threadGroup
)

Evaluates this predicate on the given thread group.

Method Detail

testback to summary
public boolean test(ThreadGroup threadGroup)

Evaluates this predicate on the given thread group.

Parameters
threadGroup:ThreadGroup

the thread group

Returns:boolean

true if the threadGroup matches the predicate, otherwise false

org.apache.commons.lang3 back to summary

public Class ThreadUtils.ThreadIdPredicate

extends Object
implements ThreadPredicate
Class Inheritance
All Implemented Interfaces
org.apache.commons.lang3.ThreadUtils.ThreadPredicate
Annotations
@Deprecated

Deprecated

Use a Predicate.

A predicate implementation which matches a thread id.

Field Summary

Modifier and TypeField and Description
private final long

Constructor Summary

AccessConstructor and Description
public
ThreadIdPredicate(final long
the threadId to match.
threadId
)

Predicate constructor

Method Summary

Modifier and TypeMethod and Description
public boolean
test(final Thread thread)

Implements org.apache.commons.lang3.ThreadUtils.ThreadPredicate.test.

Evaluates this predicate on the given thread.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

threadIdback to summary
private final long threadId

Constructor Detail

ThreadIdPredicateback to summary
public ThreadIdPredicate(final long threadId)

Predicate constructor

Parameters
threadId:long

the threadId to match.

Exceptions
IllegalArgumentException:
if the threadId is zero or negative.

Method Detail

testback to summary
public boolean test(final Thread thread)

Implements org.apache.commons.lang3.ThreadUtils.ThreadPredicate.test.

Doc from org.apache.commons.lang3.ThreadUtils.ThreadPredicate.test.

Evaluates this predicate on the given thread.

Annotations
@Override
org.apache.commons.lang3 back to summary

public Interface ThreadUtils.ThreadPredicate

Known Direct Implementers
org.apache.commons.lang3.ThreadUtils.AlwaysTruePredicate, org.apache.commons.lang3.ThreadUtils.NamePredicate, org.apache.commons.lang3.ThreadUtils.ThreadIdPredicate
Annotations
@Deprecated
@FunctionalInterface

Deprecated

Use a Predicate.

A predicate for selecting threads.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the thread matches the predicate, otherwise false
test
(Thread
the thread
thread
)

Evaluates this predicate on the given thread.

Method Detail

testback to summary
public boolean test(Thread thread)

Evaluates this predicate on the given thread.

Parameters
thread:Thread

the thread

Returns:boolean

true if the thread matches the predicate, otherwise false