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