Class TrackableThreadFactory
- java.lang.Object
-
- org.apache.qpid.protonj2.client.util.TrackableThreadFactory
-
- All Implemented Interfaces:
ThreadFactory
public class TrackableThreadFactory extends Object implements ThreadFactory
Simple ThreadFactory object that tracks the last created thread if anAtomicReference
is provided in order to hold onto the trackedThread
reference.
-
-
Constructor Summary
Constructors Constructor Description TrackableThreadFactory(String threadName, boolean daemon)
Creates a new Thread factory that will create threads with the given name and daemon state.TrackableThreadFactory(String threadName, boolean daemon, AtomicReference<Thread> threadTracker)
Creates a new Thread factory that will create threads with the given name and daemon state.
-
-
-
Constructor Detail
-
TrackableThreadFactory
public TrackableThreadFactory(String threadName, boolean daemon)
Creates a new Thread factory that will create threads with the given name and daemon state.- Parameters:
threadName
- the name that will be used for each thread created.daemon
- should the created thread be a daemon thread.
-
TrackableThreadFactory
public TrackableThreadFactory(String threadName, boolean daemon, AtomicReference<Thread> threadTracker)
Creates a new Thread factory that will create threads with the given name and daemon state. This constructor accepts an AtomicReference to track the Thread that was last created from this factory. This is most useful for a single threaded executor where the Id of the internal execution thread needs to be known for some reason.- Parameters:
threadName
- the name that will be used for each thread created.daemon
- should the created thread be a daemon thread.threadTracker
- AtomicReference that will be updated any time a new Thread is created.
-
-
Method Detail
-
newThread
public Thread newThread(Runnable target)
- Specified by:
newThread
in interfaceThreadFactory
-
-