// Avoid race hazards demonstrated by the RaceHazard // and UnsafeAccount classes by using the synchronized // methods of SaferAccount and a synchronized statement // in SaferATM. class AccountManipulationMain { public static void main(String[] args){ // Access to this account is shared by the three threads. SaferAccount acc = new SaferAccount(); // Make regular debits of the given amount. new Thread(new DirectDebit(acc)).start(); // Make regular deposits into the account. new Thread(new Saver(acc)).start(); // Allow the user to withdraw money. new Thread(new SaferATM(acc)).start(); } }