Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import scala.actors.Actor
- import scala.actors.Actor._
- object Akt1 extends Actor {
- def act() {
- while (true) {
- receive {
- case a : Int => {
- if (a < 10) {
- print(a +", ")
- val next = a+1
- Akt2 ! next
- Akt3 ! next
- } else {
- exit()
- }
- }
- }
- }
- }
- }
- object Akt2 extends Actor {
- def act() {
- while (true) {
- receive {
- case a : Int => {
- if (a < 10) {
- print(a +", ")
- val next = a+1
- Akt1 ! next
- Akt3 ! next
- } else {
- exit()
- }
- }
- }
- }
- }
- }
- object Akt3 extends Actor {
- def act() {
- while (true) {
- receive {
- case a : Int => {
- if (a < 10) {
- print(a +", ")
- val next = a+1
- Akt1 ! next
- Akt2 ! next
- } else {
- exit()
- }
- }
- }
- }
- }
- }
- object Main {
- def main(args : Array[String]) : Unit = {
- Akt1.start()
- Akt2.start()
- Akt3.start()
- Akt1 ! 0
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement