|
Scala example source code file (t3412.scala)
The Scala t3412.scala source code
import scala.actors._, scala.actors.Actor._, scala.actors.Futures._
object Test {
def main(args: Array[String]) {
val a = actor {
loop { react {
case i: Int => reply(i * 2)
case 'stop => exit()
} }
}
val fts = for (_ <- 1 to 1000)
yield a !! (3, {case x: Int => x})
def respondAll(fts: List[Future[Int]], cnt: Int): Unit =
fts match {
case List() => a ! 'stop
case ft :: rest =>
if (cnt % 100 == 0)
println(ft())
respondAll(rest, cnt + 1)
}
actor {
respondAll(fts.toList, 0)
}
}
}
Other Scala examples (source code examples)Here is a short list of links related to this Scala t3412.scala source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.