diff options
Diffstat (limited to 'Java-Kompendium/kap20/2/src/main/java/Server.java')
| -rw-r--r-- | Java-Kompendium/kap20/2/src/main/java/Server.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Java-Kompendium/kap20/2/src/main/java/Server.java b/Java-Kompendium/kap20/2/src/main/java/Server.java new file mode 100644 index 0000000..14c013a --- /dev/null +++ b/Java-Kompendium/kap20/2/src/main/java/Server.java @@ -0,0 +1,31 @@ +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(); + } + } +} |
