com.notuvy.thread
Class NamedThreadFactory

java.lang.Object
  extended by com.notuvy.thread.NamedThreadFactory
All Implemented Interfaces:
ThreadFactory

public class NamedThreadFactory
extends Object
implements ThreadFactory

A ThreadFactory that sets an explicit name for the Thread and also defaults it to be a daemon and sets a simple uncaught exception handler. It also keeps track of all produced threads, so it can check if the current thread originated from this factory.

Author:
murali

Field Summary
protected static org.apache.log4j.Logger LOG
           
 
Constructor Summary
NamedThreadFactory(String pName)
           
NamedThreadFactory(String pName, boolean pDaemon)
           
NamedThreadFactory(String pName, boolean pDaemon, Thread.UncaughtExceptionHandler pHandler)
           
 
Method Summary
 String getName()
           
 Thread newThread(Runnable pRunnable)
           
 boolean originatedCurrent()
          Determine whether the current thread originated from this factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.log4j.Logger LOG
Constructor Detail

NamedThreadFactory

public NamedThreadFactory(String pName,
                          boolean pDaemon,
                          Thread.UncaughtExceptionHandler pHandler)

NamedThreadFactory

public NamedThreadFactory(String pName,
                          boolean pDaemon)

NamedThreadFactory

public NamedThreadFactory(String pName)
Method Detail

getName

public String getName()

originatedCurrent

public boolean originatedCurrent()
Determine whether the current thread originated from this factory.

Returns:
a boolean flag indicating that this factory originated the current thread.

newThread

public Thread newThread(Runnable pRunnable)
Specified by:
newThread in interface ThreadFactory


Copyright © 2013. All Rights Reserved.