Exemplo n.º 1
0
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj != null && obj.getClass() == Account.class) {
     Account target = (Account) obj;
     return target.getAccountNo().equals(accountNo);
   }
   return false;
 }
Exemplo n.º 2
0
 @Override
 // Keep subtracting an amount from the account
 public void run() {
   while (true) {
     account.withdraw((int) (Math.random() * 10) + 1);
   }
 }
Exemplo n.º 3
0
 @Override
 // Keep adding an amount to the account
 public void run() {
   try { // Purposely delay it to let the withdraw method proceed
     while (true) {
       account.deposit((int) (Math.random() * 10) + 1);
       Thread.sleep(1000);
     }
   } catch (InterruptedException ex) {
     ex.printStackTrace();
   }
 }