Update Java STM API to include STM utils

This commit is contained in:
Peter Vlugter 2011-03-04 10:34:46 +01:00
parent ec84822675
commit f8082436dd
8 changed files with 253 additions and 0 deletions

View file

@ -0,0 +1,27 @@
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();
}
}