Package qupath.lib.common
Class ThreadTools
java.lang.Object
qupath.lib.common.ThreadTools
Create a thread factory that supports adding a prefix to the name and setting daemon status.
This helps with debugging, e.g. using visualvm
- Author:
- Pete Bankhead
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ThreadFactory
createThreadFactory
(String prefix, boolean daemon) Create a named thread factory withThread.NORM_PRIORITY
.static ThreadFactory
createThreadFactory
(String prefix, boolean daemon, int priority) Create a named thread factory with a specified priority.static int
Get the requested level of parallelism.static void
setParallelism
(int nThreads) Set the requested level of parallelism.
-
Constructor Details
-
ThreadTools
public ThreadTools()
-
-
Method Details
-
createThreadFactory
Create a named thread factory with a specified priority.- Parameters:
prefix
-daemon
-priority
-- Returns:
-
createThreadFactory
Create a named thread factory withThread.NORM_PRIORITY
.- Parameters:
prefix
-daemon
-- Returns:
-
setParallelism
public static void setParallelism(int nThreads) Set the requested level of parallelism. Note that for interactive use this is usually set through the user interface and shouldn't be modified elsewhere to maintain consistency.- Parameters:
nThreads
-
-
getParallelism
public static int getParallelism()Get the requested level of parallelism. Other classes that make use of thread pools can use this to help balance multithreading with memory use. The default value isForkJoinPool.getCommonPoolParallelism()
.- Returns:
-