summaryrefslogtreecommitdiff
path: root/test/files/jvm/t3470.scala
blob: bcb1d4f8de40f2ab4c545795bdbea0a52a18c26b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@deprecated("Suppress warnings", since="2.11")
object Test {
  import scala.actors._

  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()
  }

}