sbt / sbt-remote-control

Create and manage sbt process using unicorns and forks
Other
74 stars 14 forks source link

Configure background thread pool so that it resizes #236

Closed pvlugter closed 9 years ago

pvlugter commented 9 years ago

Currently only one background job will run at a time, with other jobs queued, but given the configuration and comments I'm guessing that this wasn't intended.

Using an unbounded queue means that the thread pool won't grow beyond the specified core size. From the javadoc for ThreadPoolExecutor: "If there are more than corePoolSize but less than maximumPoolSize threads running, a new thread will be created only if the queue is full".

Switching to SynchronousQueue (as used by Executors.newCachedThreadPool) means that there's no queueing and gives the behaviour of growing the thread pool up to the maximum, shrinking based on the keep alive timeout, and throws RejectedExecutionException if the maximum is reached.

havocp commented 9 years ago

Doh. I've done that in the past too, but apparently I don't learn quickly. thanks