Exemplo n.º 1
0
 @Override
 // Keep subtracting an amount from the account
 public void run() {
   while (true) {
     account.withdraw((int) (Math.random() * 10) + 1);
   }
 }
Exemplo n.º 2
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();
   }
 }