public class ServiceThreadFactory extends Object implements ThreadFactory
singleThreadExecutor(String, boolean),
exists to simplify the construction of an executor with a single well-named
threads.
Example
ExecutorService exec = ServiceThreadFactory.newSingleThreadExecutor("live", true)
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_NAMING_FORMAT
Default format for thread names: "%s-%03d"
|
| Constructor and Description |
|---|
ServiceThreadFactory(String name,
boolean daemons)
Create an instance with the default naming format
|
ServiceThreadFactory(String name,
boolean daemons,
String namingFormat)
Create an instance
|
| Modifier and Type | Method and Description |
|---|---|
Thread |
newThread(Runnable r) |
static ExecutorService |
singleThreadExecutor(String name,
boolean daemons)
Create a single thread executor using this naming policy
|
public static final String DEFAULT_NAMING_FORMAT
public ServiceThreadFactory(String name, boolean daemons, String namingFormat)
name - base thread namedaemons - flag to indicate the threads should be marked as daemonsnamingFormat - format string to generate thread names frompublic ServiceThreadFactory(String name, boolean daemons)
name - base thread namedaemons - flag to indicate the threads should be marked as daemonspublic Thread newThread(Runnable r)
newThread in interface ThreadFactorypublic static ExecutorService singleThreadExecutor(String name, boolean daemons)
name - base thread namedaemons - flag to indicate the threads should be marked as daemonsCopyright © 2014–2015 The Apache Software Foundation. All rights reserved.