Loading src/main/java/ch15/ryanmonica/RyanAndMonicaStatementTest.java +2 −4 Changes for src/main/java/ch15/ryanmonica/RyanAndMonicaStatementTest.java: 2 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ public class RyanAndMonicaStatementTest { public static void main(String[] args) throws InterruptedException { BankAccountStatement account = new BankAccountStatement(); ExecutorService executor = Executors.newCachedThreadPool(); executor.execute(new RyanAndMonicaStatementJob("Ryan", account, 5)); executor.execute(new RyanAndMonicaStatementJob("Ryan", account, 20)); executor.execute(new StatementReaderAccountant("Monica", account)); executor.execute(new StatementReaderAccountant("Accountant", account)); executor.execute(new StatementReaderAccountant("Bank Manager", account)); Loading @@ -31,7 +31,7 @@ class RyanAndMonicaStatementJob implements Runnable { } public void run() { for (int i = 0; i < 20; i++) { for (int i = 0; i < 5; i++) { goShopping(amountToSpend); } } Loading @@ -58,14 +58,12 @@ class StatementReaderAccountant implements Runnable { @Override public void run() { for (int i = 0; i < 10; i++) { List<Transaction> statement = account.getStatement(); for (Transaction transaction : statement) { System.out.println(name + " read " + transaction); } } } } class BankAccountStatement { private final List<Transaction> statement = new CopyOnWriteArrayList<>(); Loading Loading
src/main/java/ch15/ryanmonica/RyanAndMonicaStatementTest.java +2 −4 Changes for src/main/java/ch15/ryanmonica/RyanAndMonicaStatementTest.java: 2 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ public class RyanAndMonicaStatementTest { public static void main(String[] args) throws InterruptedException { BankAccountStatement account = new BankAccountStatement(); ExecutorService executor = Executors.newCachedThreadPool(); executor.execute(new RyanAndMonicaStatementJob("Ryan", account, 5)); executor.execute(new RyanAndMonicaStatementJob("Ryan", account, 20)); executor.execute(new StatementReaderAccountant("Monica", account)); executor.execute(new StatementReaderAccountant("Accountant", account)); executor.execute(new StatementReaderAccountant("Bank Manager", account)); Loading @@ -31,7 +31,7 @@ class RyanAndMonicaStatementJob implements Runnable { } public void run() { for (int i = 0; i < 20; i++) { for (int i = 0; i < 5; i++) { goShopping(amountToSpend); } } Loading @@ -58,14 +58,12 @@ class StatementReaderAccountant implements Runnable { @Override public void run() { for (int i = 0; i < 10; i++) { List<Transaction> statement = account.getStatement(); for (Transaction transaction : statement) { System.out.println(name + " read " + transaction); } } } } class BankAccountStatement { private final List<Transaction> statement = new CopyOnWriteArrayList<>(); Loading