Top Description Fields Constructors Methods
net.sf.ehcache.util

public Class NamedThreadFactory

extends Object
implements ThreadFactory
Class Inheritance
All Implemented Interfaces
java.util.concurrent.ThreadFactory
Imports
java.util.concurrent.ThreadFactory, java.util.concurrent.atomic.AtomicInteger

A ThreadFactory that sets names to the threads created by this factory. Threads created by this factory will take names in the form of the string namePrefix + " thread-" + threadNum where threadNum is the count of threads created by this type of factory.
Author
Abhishek Sanoujam

Field Summary

Modifier and TypeField and Description
private final boolean
private final String
private static AtomicInteger

Constructor Summary

AccessConstructor and Description
public
NamedThreadFactory(String
Prefix for names of threads
namePrefix
,
boolean daemon)

Constructor accepting the prefix of the threads that will be created by this ThreadFactory

public
NamedThreadFactory(String
Prefix for names of threads
namePrefix
)

Constructor accepting the prefix of the threads that will be created by this ThreadFactory

Method Summary

Modifier and TypeMethod and Description
public Thread
newThread(Runnable
a runnable to be executed by new thread instance
runnable
)

Implements java.util.concurrent.ThreadFactory.newThread.

Returns a new thread using a name as specified by this factory Constructs a new unstarted Thread to run the given runnable.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

daemonback to summary
private final boolean daemon
namePrefixback to summary
private final String namePrefix
threadNumberback to summary
private static AtomicInteger threadNumber

Constructor Detail

NamedThreadFactoryback to summary
public NamedThreadFactory(String namePrefix, boolean daemon)

Constructor accepting the prefix of the threads that will be created by this ThreadFactory

Parameters
namePrefix:String

Prefix for names of threads

NamedThreadFactoryback to summary
public NamedThreadFactory(String namePrefix)

Constructor accepting the prefix of the threads that will be created by this ThreadFactory

Parameters
namePrefix:String

Prefix for names of threads

Method Detail

newThreadback to summary
public Thread newThread(Runnable runnable)

Implements java.util.concurrent.ThreadFactory.newThread.

Doc from java.util.concurrent.ThreadFactory.newThread.

Returns a new thread using a name as specified by this factory Constructs a new unstarted Thread to run the given runnable.

Parameters
runnable:Runnable

a runnable to be executed by new thread instance

Returns:Thread

constructed thread, or null if the request to create a thread is rejected