doanduyhai/Achilles — pull request #150 by obourgain (2014-11-10 11:40:18+00:00)
Title: better defaults for default executor

The default executor configuration was using an Executors.newCachedThreadPool() which :
1) allowing an unlimited number of threads
2) using a SynchronousQueue
3) thread names are default ones, like pool-n-thread-m which does not help to find what is happening on these thread

For point 1, it is bad practice to allow uncontrolled thread creation, so this PR cap the thread count to 10.

For point 2, the SynchronousQueue is blocking on put() as long as a consumer thread does not take() the Runnable, this lead on a profiling session on a server used to benchmark an application to have a quite high time spent in this code. Using a LinkedBlockingQueue capped at 1000 (to avoid OOM if tasks are pilling to fast) should improve this behavior.

For point 3, the thread will be named "achilles-default-executor-n"

Thread are also made daemon.

Altought I did not set a RejectionPolicy, I think a ThreadPoolExecutor.CallerRunsPolicy#CallerRunsPolicy would be a good default choice. This may be subject to discussion.