|
Scala example source code file (t3470.scala)
The Scala t3470.scala source code
import scala.actors._
object Test {
def expectActorState(a: Reactor[T] forSome { type T }, s: Actor.State.Value) {
var done = false
var i = 0
while (!done) {
i = i + 1
if (i == 10) { // only wait for 2 seconds total
println("FAIL ["+a+": expected "+s+"]")
done = true
}
Thread.sleep(200)
if (a.getState == s) // success
done = true
}
}
def main(args: Array[String]) {
val a = new Actor { var c = 0; def act() = { c += 1; println("A: started: " + c) } }
a.start()
expectActorState(a, Actor.State.Terminated)
a.restart()
expectActorState(a, Actor.State.Terminated)
a.restart()
}
}
Other Scala examples (source code examples)Here is a short list of links related to this Scala t3470.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.