Add untyped transactor
This commit is contained in:
parent
4cdc46c23f
commit
db6d90df43
22 changed files with 422 additions and 39 deletions
35
akka-stm/src/test/java/akka/stm/example/RefExample.java
Normal file
35
akka-stm/src/test/java/akka/stm/example/RefExample.java
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package akka.stm.example;
|
||||
|
||||
import akka.stm.*;
|
||||
|
||||
public class RefExample {
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
System.out.println("Ref example");
|
||||
System.out.println();
|
||||
|
||||
final Ref<Integer> ref = new Ref<Integer>(0);
|
||||
|
||||
Integer value1 = new Atomic<Integer>() {
|
||||
public Integer atomically() {
|
||||
return ref.get();
|
||||
}
|
||||
}.execute();
|
||||
|
||||
System.out.println("value 1: " + value1);
|
||||
|
||||
new Atomic() {
|
||||
public Object atomically() {
|
||||
return ref.set(5);
|
||||
}
|
||||
}.execute();
|
||||
|
||||
Integer value2 = new Atomic<Integer>() {
|
||||
public Integer atomically() {
|
||||
return ref.get();
|
||||
}
|
||||
}.execute();
|
||||
|
||||
System.out.println("value 2: " + value2);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue