//посмотрел у других, разницы не могу найти package com.javarush.task.task32.task3208; import java.rmi.AlreadyBoundException; import java.rmi.NotBoundException; import java.rmi.Remote; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; /* RMI-2 */ public class Solution { public static Registry registry; // Pretend we're starting an RMI client as the CLIENT_THREAD thread public static Thread CLIENT_THREAD = new Thread(new Runnable() { @Override public void run() { try { for (String bindingName : registry.list()) { Animal service = (Animal) registry.lookup(bindingName); service.printName(); service.speak(); } } catch (RemoteException e) { e.printStackTrace(); } catch (NotBoundException e) { e.printStackTrace(); } } }); // Pretend we're starting an RMI server as the SERVER_THREAD thread public static Thread SERVER_THREAD = new Thread(new Runnable() { @Override public void run() { final String BINDING_dog = "server.dog"; final String BINDING_cat = "server.cat"; try { registry = LocateRegistry.createRegistry(2099); final Cat cat = new Cat("Vaska"); final Dog dog = new Dog("Polkan"); Remote remoteCat = UnicastRemoteObject.exportObject(cat, 0); Remote remoteDog = UnicastRemoteObject.exportObject(dog, 0); registry.bind(BINDING_cat, remoteCat); registry.bind(BINDING_dog, remoteDog); Thread.sleep(2000); } catch (RemoteException e) { e.printStackTrace(System.err); } catch (AlreadyBoundException e) { e.printStackTrace(System.err); } catch (InterruptedException e) { e.printStackTrace(System.err); } } }); public static void main(String[] args) throws InterruptedException { // Starting an RMI server thread SERVER_THREAD.start(); Thread.sleep(1000); // Start the client CLIENT_THREAD.start(); } }