scala/ScalaBook/chapter-07/futures.scala
import scala.actors._
import scala.actors.Futures._
object ForkJoinExample {
def main(args : Array[String]) {
//Fork
val futures = for(i <- (1 to Runtime.getRuntime.availableProcessors).toList)
yield future { println("Hello from Processor "+i); Thread.sleep(1000); 1 }
val t = System.nanoTime
//Join
val numProcs = (for (f <- futures) yield f()).reduceRight(_+_)
//If this is is much greater than 1, you probably aren't doing it right.
println((System.nanoTime - t) * 1.0E-9)
println("You have " + numProcs + " processors.")
}
}