class Concurrent::JavaExecutorService

@!visibility private
@!macro abstract_executor_service_public_api

def kill

def kill
  synchronize do
    @executor.shutdownNow
    nil
  end
end

def ns_running?

def ns_running?
  !(ns_shuttingdown? || ns_shutdown?)
end

def ns_shutdown?

def ns_shutdown?
  @executor.isTerminated
end

def ns_shuttingdown?

def ns_shuttingdown?
  @executor.isShutdown && !@executor.isTerminated
end

def post(*args, &task)

def post(*args, &task)
  raise ArgumentError.new('no block given') unless block_given?
  return fallback_action(*args, &task).call unless running?
  @executor.submit Job.new(args, task)
  true
rescue Java::JavaUtilConcurrent::RejectedExecutionException
  raise RejectedExecutionError
end

def shutdown

def shutdown
  synchronize do
    @executor.shutdown
    nil
  end
end

def wait_for_termination(timeout = nil)

def wait_for_termination(timeout = nil)
  if timeout.nil?
    ok = @executor.awaitTermination(60, java.util.concurrent.TimeUnit::SECONDS) until ok
    true
  else
    @executor.awaitTermination(1000 * timeout, java.util.concurrent.TimeUnit::MILLISECONDS)
  end
end