Skip to content

Instantly share code, notes, and snippets.

View aposwolsky's full-sized avatar

Adam Poswolsky aposwolsky

View GitHub Profile
import com.twitter.util.{Duration, Future, FuturePool, Try}
import java.util.concurrent.{LinkedBlockingQueue, ThreadPoolExecutor, TimeUnit}
val poolSize = 4
val queue = new LinkedBlockingQueue[Runnable]()
val executor = new ThreadPoolExecutor(poolSize, poolSize, 0L, TimeUnit.MILLISECONDS, queue)
val futurePool = FuturePool(executor)
def doWork(n: Int): Int = {
Thread.sleep(1000)