Package org.atlanmod.commons.concurrent
Class MoreThreads
- java.lang.Object
-
- org.atlanmod.commons.concurrent.MoreThreads
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidexecuteAtExit(Runnable task)Adds a shutdown hook that will execute thetaskwhen the application will exit.static ThreadFactorynewThreadFactory()Creates a newThreadFactorythat creates daemon threads.static ThreadFactorynewThreadFactory(String prefix)Creates a newThreadFactorythat creates daemon threads with a defined prefixed name.
-
-
-
Method Detail
-
newThreadFactory
@Nonnull public static ThreadFactory newThreadFactory()
Creates a newThreadFactorythat creates daemon threads.- Returns:
- a new thread factory
- See Also:
newThreadFactory(String)
-
newThreadFactory
@Nonnull public static ThreadFactory newThreadFactory(@Nullable String prefix)
Creates a newThreadFactorythat creates daemon threads with a defined prefixed name.- Parameters:
prefix- the prefix of the name of created threads; ifnullthe default name will be used- Returns:
- a new thread factory
- See Also:
Executors.defaultThreadFactory()
-
executeAtExit
public static void executeAtExit(Runnable task)
Adds a shutdown hook that will execute thetaskwhen the application will exit.- Parameters:
task- the task to execute- Throws:
NullPointerException- if thetaskisnull
-
-