org.hibernate.search.util.impl

## Class Executors

- java.lang.Object
- - org.hibernate.search.util.impl.Executors

-     public final class Executors
      extends Object

  Helper class to create threads; these threads are grouped and named to be identified in a profiler.
  Author:
    Sanne Grinovero

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Executors.BlockPolicy` A handler for rejected tasks that will have the caller block until space is available.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `QUEUE_MAX_LENGTH`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static ThreadPoolExecutor` | `newFixedThreadPool(int threads, String groupname)` Creates a new fixed size ThreadPoolExecutor.
    `static ThreadPoolExecutor` | `newFixedThreadPool(int threads, String groupname, int queueSize)` Creates a new fixed size ThreadPoolExecutor
    `static ThreadPoolExecutor` | `newScalableThreadPool(int threadsMin, int threadsMax, String groupname, int queueSize)` Creates a dynamically scalable threadpool having an upper bound of threads and queue size which ultimately falls back to a CallerRunsPolicy.
    `static ScheduledExecutorService` | `newScheduledThreadPool(String groupname)` Creates an executor for recurring tasks

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### QUEUE_MAX_LENGTH

          public static final int QUEUE_MAX_LENGTH

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### 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

    - #### newScheduledThreadPool

          public static ScheduledExecutorService newScheduledThreadPool(String groupname)

      Creates an executor for recurring tasks
      Parameters:
        `groupname` - a label to identify the threadpool; useful for profiling.
      Returns:
        instance of `ScheduledThreadPoolExecutor`

    - #### newScalableThreadPool

          public static ThreadPoolExecutor newScalableThreadPool(int threadsMin,
                                                                 int threadsMax,
                                                                 String groupname,
                                                                 int queueSize)

      Creates a dynamically scalable threadpool having an upper bound of threads and queue size which ultimately falls back to a CallerRunsPolicy.
      Parameters:
        `threadsMin` - initial and minimum threadpool size
        `threadsMax` - maximumx threadpool size
        `groupname` - used to assign nice names to the threads to help diagnostics and tuning
        `queueSize` - maximum size of the blocking queue holding the work
      Returns:
        the new Executor instance

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved