mp
05/23/2018, 7:51 PMval queue = BlockingQueue<List<int>>() // or some other type
val outQueue = BlockingQueue<...>()
val executor = Executors.newFixedThreadPool(4) // sized appropriately for your system. See Runtime class for # of CPUs
repeat(4) { executor.submit {
while(true) {
val i = queue.take()
if (i.isEmpty()) {
return
}
outQueue.put(slowCalculation(i))
}}}