Skip to content

Instantly share code, notes, and snippets.

@computereasy
computereasy / ThreadPoolExample.scala
Created December 1, 2016 15:32
Scala thread pool example
import java.util.concurrent.Executors
val pool = java.util.concurrent.Executors.newFixedThreadPool(2)
1 to 10 foreach { x =>
pool.execute(
new Runnable {
def run {
Thread.sleep(2000)
println("n: %s, thread: %s".format(x, Thread.currentThread.getId))