class Concurrent::JavaFixedThreadPool

@!macro fixed_thread_pool

def initialize(num_threads, opts = {})

Other tags:
    See: http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#newFixedThreadPool-int- -

Raises:
  • (ArgumentError) - if `overflow_policy` is not a known policy
  • (ArgumentError) - if `num_threads` is less than or equal to zero

Options Hash: (**opts)
  • :overflow_policy (Symbol) -- the overflow policy

Parameters:
  • opts (Hash) -- the options defining pool behavior.
def initialize(num_threads, opts = {})
  @overflow_policy = opts.fetch(:overflow_policy, :abort)
  @max_queue = 0
  raise ArgumentError.new('number of threads must be greater than zero') if num_threads < 1
  raise ArgumentError.new("#{@overflow_policy} is not a valid overflow policy") unless OVERFLOW_POLICIES.keys.include?(@overflow_policy)
  @executor = java.util.concurrent.Executors.newFixedThreadPool(num_threads)
  @executor.setRejectedExecutionHandler(OVERFLOW_POLICIES[@overflow_policy].new)
  set_shutdown_hook
end