import scala.actors._
import scala.actors.Futures._
object ForkJoinExample {
def main(args : Array[String]) {
def power(i : Int) : BigInt = {
var p : BigInt = 1
for ( i <- 1 to 100) p*= i
return p
}
//Fork
val futures = for(i <- (2 to 10).toList)
yield future { power(i) }
val t = nanoTime
//Join
val sum = (for (f <- futures) yield f()).reduceRight(_+_)
println((nanoTime - t)* 1.0E-9)
println(sum)
}
}