public class

CustomizableThreadCreator

extends Object
implements Serializable
java.lang.Object
   ↳ org.springframework.util.CustomizableThreadCreator
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Simple customizable helper class for creating threads. Provides various bean properties, such as thread name prefix, thread priority, etc.

Serves as base class for thread factories such as CustomizableThreadFactory.

Summary

Public Constructors
CustomizableThreadCreator()
Create a new CustomizableThreadCreator with default thread name prefix.
CustomizableThreadCreator(String threadNamePrefix)
Create a new CustomizableThreadCreator with the given thread name prefix.
Public Methods
Thread createThread(Runnable runnable)
Template method for the creation of a Thread.
ThreadGroup getThreadGroup()
Return the thread group that threads should be created in (or null) for the default group.
String getThreadNamePrefix()
Return the thread name prefix to use for the names of newly created threads.
int getThreadPriority()
Return the priority of the threads that this factory creates.
boolean isDaemon()
Return whether this factory should create daemon threads.
void setDaemon(boolean daemon)
Set whether this factory is supposed to create daemon threads, just executing as long as the application itself is running.
void setThreadGroup(ThreadGroup threadGroup)
Specify the thread group that threads should be created in.
void setThreadGroupName(String name)
Specify the name of the thread group that threads should be created in.
void setThreadNamePrefix(String threadNamePrefix)
Specify the prefix to use for the names of newly created threads.
void setThreadPriority(int threadPriority)
Set the priority of the threads that this factory creates.
Protected Methods
String getDefaultThreadNamePrefix()
Build the default thread name prefix for this factory.
String nextThreadName()
Return the thread name to use for a newly created thread.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public CustomizableThreadCreator ()

Also: SpringCore

Create a new CustomizableThreadCreator with default thread name prefix.

public CustomizableThreadCreator (String threadNamePrefix)

Also: SpringCore

Create a new CustomizableThreadCreator with the given thread name prefix.

Parameters
threadNamePrefix the prefix to use for the names of newly created threads

Public Methods

public Thread createThread (Runnable runnable)

Also: SpringCore

Template method for the creation of a Thread.

Default implementation creates a new Thread for the given Runnable, applying an appropriate thread name.

Parameters
runnable the Runnable to execute
See Also

public ThreadGroup getThreadGroup ()

Also: SpringCore

Return the thread group that threads should be created in (or null) for the default group.

public String getThreadNamePrefix ()

Also: SpringCore

Return the thread name prefix to use for the names of newly created threads.

public int getThreadPriority ()

Also: SpringCore

Return the priority of the threads that this factory creates.

public boolean isDaemon ()

Also: SpringCore

Return whether this factory should create daemon threads.

public void setDaemon (boolean daemon)

Also: SpringCore

Set whether this factory is supposed to create daemon threads, just executing as long as the application itself is running.

Default is "false": Concrete factories usually support explicit cancelling. Hence, if the application shuts down, Runnables will by default finish their execution.

Specify "true" for eager shutdown of threads which still actively execute a Runnable.

public void setThreadGroup (ThreadGroup threadGroup)

Also: SpringCore

Specify the thread group that threads should be created in.

public void setThreadGroupName (String name)

Also: SpringCore

Specify the name of the thread group that threads should be created in.

public void setThreadNamePrefix (String threadNamePrefix)

Also: SpringCore

Specify the prefix to use for the names of newly created threads. Default is "SimpleAsyncTaskExecutor-".

public void setThreadPriority (int threadPriority)

Also: SpringCore

Set the priority of the threads that this factory creates. Default is 5.

See Also

Protected Methods

protected String getDefaultThreadNamePrefix ()

Also: SpringCore

Build the default thread name prefix for this factory.

Returns
  • the default thread name prefix (never null)

protected String nextThreadName ()

Also: SpringCore

Return the thread name to use for a newly created thread.

Default implementation returns the specified thread name prefix with an increasing thread count appended: for example, "SimpleAsyncTaskExecutor-0".