MCPcopy Create free account
hub / github.com/careercup/ctci / main

Method main

java/Chapter 16/IntroductionLocks/Intro.java:5–28  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

3public class Intro {
4
5 public static void main(String[] args) {
6 NoLockATM noLockATM = new NoLockATM();
7 LockedATM lockedATM = new LockedATM();
8 MyClass thread1 = new MyClass(noLockATM, lockedATM);
9 MyClass thread2 = new MyClass(noLockATM, lockedATM);
10
11 thread1.start();
12 thread2.start();
13
14 try {
15 Thread.sleep(1000);
16 } catch (InterruptedException e) {
17 // TODO Auto-generated catch block
18 e.printStackTrace();
19 }
20 thread1.waitUntilDone();
21 thread2.waitUntilDone();
22
23 System.out.println("NoLock ATM: " + noLockATM.getBalance());
24 System.out.println("Locked ATM: " + lockedATM.getBalance());
25 int v = thread1.delta + thread2.delta + 100;
26 System.out.println("Should Be: " + v);
27 System.out.println("Program terminating.");
28 }
29
30}

Callers

nothing calls this directly

Calls 3

waitUntilDoneMethod · 0.95
getBalanceMethod · 0.95
getBalanceMethod · 0.95

Tested by

no test coverage detected