Skip to content

Instantly share code, notes, and snippets.

View johanandren's full-sized avatar
👻
hakking

Johan Andrén johanandren

👻
hakking
View GitHub Profile
@runarorama
runarorama / gist:5af95832695e02426d32
Created May 4, 2015 20:51
Superstitious parent mode
import java.util.concurrent._
/**
* A thread pool for superstitious parent threads who
* know they shouldn't let their child threads back in the pool after
* eating, without waiting at least `crampFactor` milliseconds.
*/
object Superstitious {
def pool(crampFactor: Long) = new ThreadPoolExecutor(
0, Int.MaxValue, 60L, TimeUnit.SECONDS, new SynchronousQueue[Runnable]) {