Ejemplo n.º 1
0
  public synchronized void transfer(int amount, int destiny) throws RemoteException {
    clock[id]++;
    monitor.begin(id, destiny, amount, clock);
    balance -= amount;
    BankInterface bank = null;

    try {
      bank = (BankInterface) registry.lookup("//localhost/bank" + destiny);
    } catch (Exception e) {
      e.printStackTrace();
    }

    sync(bank.receive(amount, clock));
    clock[id]++;
    monitor.end(id, destiny, amount, clock);
  }
Ejemplo n.º 2
0
 public synchronized int[] receive(int balance, int[] sequence) throws RemoteException {
   sync(sequence);
   this.balance += balance;
   return sequence;
 }