Class LtThreadPoolFactory

java.lang.Object
org.languagetool.tools.LtThreadPoolFactory

public final class LtThreadPoolFactory extends Object
  • Field Details

  • Constructor Details

    • LtThreadPoolFactory

      private LtThreadPoolFactory()
  • Method Details

    • createFixedThreadPoolExecutor

      public static ThreadPoolExecutor createFixedThreadPoolExecutor(@NotNull String identifier, int maxThreads, int maxTaskInQueue, boolean isDaemon, @NotNull Thread.UncaughtExceptionHandler exceptionHandler, boolean reuse)
      Parameters:
      identifier - Name of the thread-pool, will be used as name of the threads in the threadPool
      maxThreads - Number of parallel threads running in this pool
      maxTaskInQueue - Number of maximum Task in the pool queue
      isDaemon - Run the threads as daemon threads
      exceptionHandler - Handler for exceptions in Thread
      reuse - True if thread-pool should be reused
      Returns:
      a Fixed ThreadPoolExecutor
    • createFixedThreadPoolExecutor

      public static ThreadPoolExecutor createFixedThreadPoolExecutor(@NotNull String identifier, int corePool, int maxThreads, int maxTaskInQueue, long keepAliveTimeSeconds, boolean isDaemon, @NotNull Thread.UncaughtExceptionHandler exceptionHandler, boolean reuse)
      Parameters:
      identifier - Name of the thread-pool, will be used as name of the threads in the threadPool
      corePool - Number of core pool threads
      maxThreads - Maximum number of parallel threads running in this pool
      maxTaskInQueue - Number of maximum Task in the pool queue
      keepAliveTimeSeconds - keep-alive time for idle threads
      isDaemon - Run the threads as daemon threads
      exceptionHandler - Handler for exceptions in Thread
      reuse - True if thread-pool should be reused
      Returns:
      a Fixed ThreadPoolExecutor
    • getNewThreadPoolExecutor

      @NotNull private static ThreadPoolExecutor getNewThreadPoolExecutor(@NotNull String identifier, int corePool, int maxThreads, int maxTaskInQueue, long keepAliveTimeSeconds, boolean isDaemon, @NotNull Thread.UncaughtExceptionHandler exceptionHandler)
    • getFixedThreadPoolExecutor

      public static Optional<ThreadPoolExecutor> getFixedThreadPoolExecutor(@NotNull String identifier)
      Parameters:
      identifier - Name of an already created tread-pool
      Returns:
      An optional of ThreadPoolExecutor (Null or Object)