Skip to content

Instantly share code, notes, and snippets.

Avatar

computereasy

View GitHub Profile
View ThreadPoolExample.scala
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))