import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; import java.util.concurrent.Semaphore; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; public class Server extends Thread { public final Semaphore lock = new Semaphore(1); public Server() throws InterruptedException { this.lock.acquire(); } @Override public void run() { try { RMIInterface server = new RMIKlasse(); RMIInterface stub = (RMIInterface) UnicastRemoteObject.exportObject((RMIInterface) server, 0); Registry registrierung = LocateRegistry.createRegistry(1099); registrierung.rebind("RMIAufgabe", stub); } catch (RemoteException e) { System.out.println("Server: "); System.out.println(e); } finally { this.lock.release(); } } }