public class MutableInt {
private int value;
public MutableInt() {
value = 0;
}
public void add(int operand) {
value += operand;
}
public int intValue() {
return value;
}
}
MutableInt total = new MutableInt();
Future<Void> f = void_fork(() -> {
synchronized(total) {
total.add(11);
}
});
total.add(10);
join(f);
System.out.println(total.intValue());
String[] texts = new String[1];
texts[0] = "";
Future<Void> a = void_fork(() -> {
synchronized(texts) {
texts[0] = texts[0] + "A";
}
});
Future<Void> b = void_fork(() -> {
synchronized(texts) {
texts[0] = texts[0] + "B";
}
});
Future<Void> c = void_fork(() -> {
texts[0] = texts[0] + "C";
});
join(a, b, c);
System.out.println(s[0]);