Class Executors

java.lang.Object
org.hibernate.search.batchindexing.Executors

public class Executors extends Object
Helper class to create threads; these threads are grouped and named to be identified in a profiler.
  • Field Details

  • Constructor Details

    • Executors

      public Executors()
  • Method Details

    • newFixedThreadPool

      public static ThreadPoolExecutor newFixedThreadPool(int threads, String groupname)
      Creates a new fixed size ThreadPoolExecutor. It's using a blockingqueue of maximum 1000 elements and the rejection policy is set to CallerRunsPolicy for the case the queue is full. These settings are required to cap the queue, to make sure the timeouts are reasonable for most jobs.
      Parameters:
      threads - the number of threads
      groupname - a label to identify the threadpool; useful for profiling.
      Returns:
      the new ExecutorService
    • newFixedThreadPool

      public static ThreadPoolExecutor newFixedThreadPool(int threads, String groupname, int queueSize)
      Creates a new fixed size ThreadPoolExecutor
      Parameters:
      threads - the number of threads
      groupname - a label to identify the threadpool; useful for profiling.
      queueSize - the size of the queue to store Runnables when all threads are busy
      Returns:
      the new ExecutorService