I'm trying to understand the RMI and I found this example:
Code:
    public interface Gioco extends Remote {
       void throwDado(Dado d) throws RemoteException;
    }

    class GiocoImpl extends UnicastRemoteObject implements Gioco {
       public GiocoImpl() throws RemoteException {
            super(); 
        }
        public void throwDado(Dado d) throws RemoteException {
            try {
              System.out.println("Tiro il dado: ");
              d.printVal();
            } catch (RemoteException ex {
                System.out.println(ex.getMessage());}
            }
        }
        public static void main(String[] args) {
          try {
            java.rmi.registry.LocateRegistry.createRegistry(2000); 
            GiocoImpl s = new GiocoImpl();
            Context namingContext = new InitialContext();
            namingContext.bind("rmi://127.0.0.1:2000/gioco", s);
          } catch(Exception e) {
            e.printStackTrace();
          } 
        }
    }

    public interface Dado extends Remote {
       void printVal() throws RemoteException;
    }

    class DadoImpl extends UnicastRemoteObject implements Dado {
        public DadoImpl() throws RemoteException {
            super(); 
        }
        public void printVal() throws RemoteException {
          Random r= new Random();
          System.out.println(r.nextInt(6));
       }
    }

    class Client {
       public static void main(String[] args) {
          try {
             Context namingContext = new InitialContext();
             Gioco g = (Gioco)namingContext.lookup("rmi://127.0.0.1:2000/gioco"); 
            System.out.println("Faccio tirare due dadi"); 
            g.throwDado(new DadoImpl());
            g.throwDado(new DadoImpl());
          } catch(Exception e) {
            e.printStackTrace();
          }
       }
    }
I executed the class GiocoImpl and then the client, and I noticed that the values of the printval() method are printed in the client window. How is this possible? Isn't the method executed into the server?