27 lines
693 B
Java
27 lines
693 B
Java
package akka.stm.example;
|
|
|
|
import akka.stm.*;
|
|
import akka.actor.*;
|
|
|
|
public class EitherOrElseExample {
|
|
public static void main(String[] args) {
|
|
System.out.println();
|
|
System.out.println("EitherOrElse example");
|
|
System.out.println();
|
|
|
|
final Ref<Integer> left = new Ref<Integer>(100);
|
|
final Ref<Integer> right = new Ref<Integer>(100);
|
|
|
|
ActorRef brancher = Actors.actorOf(Brancher.class).start();
|
|
|
|
brancher.sendOneWay(new Branch(left, right, 500));
|
|
|
|
new Atomic() {
|
|
public Object atomically() {
|
|
return right.set(right.get() + 1000);
|
|
}
|
|
}.execute();
|
|
|
|
brancher.stop();
|
|
}
|
|
}
|