I have some questions about the UnicastRemoteObject class. take the following code:
public class MaxImpl extends UnicastRemoteObject implements Max{
public MaxImpl () throws RemoteException {}
@Override
public int getMax(int[] A) throws RemoteException {
// ...
return max;
}
public static void main(String[] args) {
try {
LocateRegistry.createRegistry(1099);
MaxImpl max = new MaxImpl();
Naming.rebind("maximum", max);
} catch (RemoteException ex) {
System.out.println(ex.getMessage());
} catch (MalformedURLException ex) {
System.out.println(ex.getMessage());
}
}
}
what does the following statement do:
MaxImpl max = new MaxImpl();
the above code is executed indefinitely, Why? I suppose there's a loop:
while(true){ ServerSocket server = ...; }
generate a stub.
No.
generate a stub and create a remote object so that it can receive invocations of its remote methods from remote clients.
No.
It exports the remote object, which consists of:
Note that (1( and (2) Can be shared between remote objects using the same port so it may not happen precisely as above.
Now the existence of the thread at (2) will prevent the JVM from exiting.