Update Java STM API to include STM utils
This commit is contained in:
parent
ec84822675
commit
f8082436dd
8 changed files with 253 additions and 0 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue