Class DaemonFactory
- java.lang.Object
-
- org.simpleframework.common.thread.DaemonFactory
-
- All Implemented Interfaces:
java.util.concurrent.ThreadFactory
public class DaemonFactory extends java.lang.Object implements java.util.concurrent.ThreadFactory
TheDaemonFactory
object is used to build threads and prefix the thread with a type name. Prefixing the threads with the type that it represents allows the purpose of the thread to be determined and also provides better debug information.- Author:
- Niall Gallagher
-
-
Constructor Summary
Constructors Constructor Description DaemonFactory()
Constructor for theDaemonFactory
object.DaemonFactory(java.lang.Class type)
Constructor for theDaemonFactory
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Thread
newThread(java.lang.Runnable task)
This is used to create a thread from the provided runnable.java.lang.Thread
newThread(java.lang.Runnable task, java.lang.Class type)
This is used to create a thread from the provided runnable.
-
-
-
Constructor Detail
-
DaemonFactory
public DaemonFactory()
Constructor for theDaemonFactory
object. This will provide a thread factory that names the threads based on the type ofRunnable
the pool executes.
-
DaemonFactory
public DaemonFactory(java.lang.Class type)
Constructor for theDaemonFactory
object. This will provide a thread factory that names the threads based on the type ofRunnable
the pool executes. Each of the threads is given a unique sequence number.- Parameters:
type
- this is the type of runnable this will execute
-
-
Method Detail
-
newThread
public java.lang.Thread newThread(java.lang.Runnable task)
This is used to create a thread from the provided runnable. The thread created will contain a unique name which is prefixed with the type of task it has been created to execute. This provides some detail as to what the thread should be doing.- Specified by:
newThread
in interfacejava.util.concurrent.ThreadFactory
- Parameters:
task
- this is the task that the thread is to execute- Returns:
- this returns a thread that will executed the given task
-
newThread
public java.lang.Thread newThread(java.lang.Runnable task, java.lang.Class type)
This is used to create a thread from the provided runnable. The thread created will contain a unique name which is prefixed with the type of task it has been created to execute. This provides some detail as to what the thread should be doing.- Parameters:
task
- this is the task that the thread is to executetype
- this is the type of object the thread is to execute- Returns:
- this returns a thread that will executed the given task
-
-