Class ThreadTools

java.lang.Object
qupath.lib.common.ThreadTools

public class ThreadTools extends Object
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 Details

    • ThreadTools

      public ThreadTools()
  • Method Details

    • createThreadFactory

      public static ThreadFactory createThreadFactory(String prefix, boolean daemon, int priority)
      Create a named thread factory with a specified priority.
      Parameters:
      prefix -
      daemon -
      priority -
      Returns:
    • createThreadFactory

      public static ThreadFactory createThreadFactory(String prefix, boolean daemon)
      Create a named thread factory with Thread.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 is ForkJoinPool.getCommonPoolParallelism().
      Returns: