Package java.util.concurrent
Interface ThreadFactory
-
public interface ThreadFactoryAn object that creates new threads on demand. Using thread factories removes hardwiring of calls tonew Thread, enabling applications to use special thread subclasses, priorities, etc.The simplest implementation of this interface is just:
class SimpleThreadFactory implements ThreadFactory { public Thread newThread(Runnable r) { return new Thread(r); } }- Since:
- 1.5
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ThreadnewThread(Runnable r)Constructs a newThread.
-
-
-
Method Detail
-
newThread
@Nullable Thread newThread(Runnable r)
Constructs a newThread. Implementations may also initialize priority, name, daemon status,ThreadGroup, etc.- Parameters:
r- a runnable to be executed by new thread instance- Returns:
- constructed thread, or
nullif the request to create a thread is rejected
-
-