org.apache.ws.util.thread
Class NamedThread

java.lang.Object
  extended byjava.lang.Thread
      extended byorg.apache.ws.util.thread.NamedThread
All Implemented Interfaces:
java.lang.Runnable

public class NamedThread
extends java.lang.Thread

Subclass of Thread that provides commonly named threads for use inside a particular software application.

The main purpose of this class is to provide all threads running in the software with a consistent naming convention. When instantiating a NamedThread, if a name is provided, that name will be used as the base name for the thread. The base name will be decorated with additional information to make the thread name unique.


Nested Class Summary
static class NamedThread.ConcurrentThreadFactory
          A thread factory for use with the Concurrent API.
 
Field Summary
static java.lang.String THREAD_NAME_PREFIX
          all thread names will have this string as a prefix
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
NamedThread()
          Creates the thread with an empty base name.
NamedThread(java.lang.Runnable target)
          Creates the thread with an empty base name.
NamedThread(java.lang.Runnable target, java.lang.String name)
          Creates the thread with the given name to be used as the base name.
NamedThread(java.lang.String name)
          Creates the thread with the given name to be used as the base name.
NamedThread(java.lang.ThreadGroup group, java.lang.Runnable target)
          Creates the thread with an empty base name.
NamedThread(java.lang.ThreadGroup group, java.lang.Runnable target, java.lang.String name)
          Creates the thread with the given name to be used as the base name.
NamedThread(java.lang.ThreadGroup group, java.lang.String name)
          Creates the thread with the given name to be used as the base name.
 
Method Summary
protected static java.lang.String createThreadName(java.lang.String baseName)
          Builds a thread name that is unique to the JVM.
 java.lang.String getBaseName()
          Returns the base name used to create the thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

THREAD_NAME_PREFIX

public static final java.lang.String THREAD_NAME_PREFIX
all thread names will have this string as a prefix

See Also:
Constant Field Values
Constructor Detail

NamedThread

public NamedThread()
Creates the thread with an empty base name.

See Also:
Thread.Thread(java.lang.String)

NamedThread

public NamedThread(java.lang.Runnable target)
Creates the thread with an empty base name.

See Also:
Thread.Thread(java.lang.Runnable)

NamedThread

public NamedThread(java.lang.ThreadGroup group,
                   java.lang.Runnable target)
Creates the thread with an empty base name.

See Also:
Thread.Thread(java.lang.ThreadGroup, java.lang.Runnable)

NamedThread

public NamedThread(java.lang.String name)
Creates the thread with the given name to be used as the base name.

See Also:
Thread.Thread(java.lang.String)

NamedThread

public NamedThread(java.lang.ThreadGroup group,
                   java.lang.String name)
Creates the thread with the given name to be used as the base name.

See Also:
Thread.Thread(java.lang.ThreadGroup, java.lang.String)

NamedThread

public NamedThread(java.lang.Runnable target,
                   java.lang.String name)
Creates the thread with the given name to be used as the base name.

See Also:
Thread.Thread(java.lang.Runnable, java.lang.String)

NamedThread

public NamedThread(java.lang.ThreadGroup group,
                   java.lang.Runnable target,
                   java.lang.String name)
Creates the thread with the given name to be used as the base name.

See Also:
Thread.Thread(java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)
Method Detail

getBaseName

public java.lang.String getBaseName()
Returns the base name used to create the thread. To get the actual name of the thread, use Thread.getName(). If no name was passed into a constructor, or if null was passed, then null is returned.

Returns:
base name of the thread (the name passed into the constructor)

createThreadName

protected static java.lang.String createThreadName(java.lang.String baseName)
Builds a thread name that is unique to the JVM. The base name provided will be used as part of the thread name to further describe the thread's purpose. If the base name is null, it will not be used.

Parameters:
baseName - thread's base name
Returns:
String a String that can be used as a thread name


Copyright © 2004-2005 Apache Software Foundation. All Rights Reserved.