private ExecutorService createThreadPoolWithBoundedQueue(int threadCount) {
        BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<Runnable>(threadCount);
        RejectedExecutionHandler rejectedExecutionHandler = new ThreadPoolExecutor.CallerRunsPolicy();
        return new ProcessingLibraryThreadPoolExecutor(threadCount, threadCount, 0, TimeUnit.MILLISECONDS,
                blockingQueue, rejectedExecutionHandler, exceptionHandler);
    }
private ExecutorService createThreadPoolWithBoundedQueue ( int threadCount ) { BlockingQueue < Runnable > blockingQueue = new ArrayBlockingQueue < Runnable > ( threadCount ) ; RejectedExecutionHandler rejectedExecutionHandler = new ThreadPoolExecutor . CallerRunsPolicy ( ) ; return new ProcessingLibraryThreadPoolExecutor ( threadCount , threadCount , 0 , TimeUnit . MILLISECONDS , blockingQueue , rejectedExecutionHandler , exceptionHandler ) ; }
Helper function to create an instance of ExecutorService with bounded queue size.
<p>
When no more threads or queue slots are available because their bounds would be exceeded, the scheduled
thread pool will run the rejected task directly. Unless the executor has been shut down, in which case the
task is discarded. Note while scheduled thread poll is running rejected task, scheduled thread pool will not
poll more messages to process.
</p>
@param threadCount the number of threads.
@return {@link ExecutorService} that processes {@link CloudTrailSource}.