Hi I wonder how to measure thread pool time in scala.
Here is a example.
val pool = java.util.concurrent.Executors.newFixedThreadPool(2)
val start_time = System.nanoTime()
1 to 10 foreach { x =>
pool.execute(
new Runnable {
def run {
try{
Thread.sleep(2000)
println("n: %s, thread: %s".format(x, Thread.currentThread.getId))
}finally{
pool.shutdown()
}
}
}
)
}
val end_time = System.nanoTime()
println("time is "+(end_time - start_time)/(1e6 * 60 * 60))
But I think this is not working properly.
Is there any methods to measure the time?