I tried this code
import scala.actors.Actor
class MyActor(val id:Int) extends Actor {
def act() {
println (" ****************** starting actor: " + id)
while (true) {
Thread.sleep(1000);
println ("I'm actor " + id)
}
}
}
object Main {
def main(args:Array[String]) {
val N = 5
for (i leftArrow 1 to N) {
val a = new MyActor(i)
println (" ++++++++++ about to start actor " + a.id)
a.start
}
println (N + " actors launched?")
}
}
and got this output
++++++++++ about to start actor 1
++++++++++ about to start actor 2
++++++++++ about to start actor 3
++++++++++ about to start actor 4
++++++++++ about to start actor 5
5 actors launched?
****************** starting actor: 1
****************** starting actor: 4
****************** starting actor: 3
****************** starting actor: 2
I'm actor 4
I'm actor 3
I'm actor 1
I'm actor 2
I'm actor 4
So, what I'm missing that only four actors are actually being started? Does it depend on my computer? Some configuration? Should I start actors in a different way? Is it because I'm running that code inside netbeans?
Thank you very much !