Commit 0994ba56 authored by Trisha Gee's avatar Trisha Gee
Browse files

[Ch15] Proves that even ++ isn't atomic

parent 83b6b00e
Loading
Loading
Loading
Loading
+2 −3
Changes for src/main/java/ch15/TestSyncTest.java: 2 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ public class TestSyncTest {
    pool.shutdown();
    // make sure the pool has finished running all the updates before printing the output
    if (pool.awaitTermination(1, TimeUnit.MINUTES)) {
      System.out.println("balance.balance = " + balance.balance);
      System.out.println("balance = " + balance.balance);
    }
  }

@@ -27,8 +27,7 @@ class Balance {
  int balance = 0;

  public void increment() {
    int i = balance;
    balance = i + 1;
    balance++;
  }
}