This is the server program part
System.out.println("Client starting");
// Find the server, and register with it
System.out.println("Finding server");
RunServer server =
(RunServer)Naming.lookup("rmi://" + host + "/" +
RunServer.LOOKUP_NAME);
// Create the Agent as an un-exported Remote
AgentImpl guts = new AgentImpl();
// This should cause the server to call us back.
System.out.println("Passing Agent to server");
RemoteStub rs = server.connect(guts);
System.out.println(rs);
RemoteRef rr = rs.getRef();
System.out.println("Client program ready.");
Class[] args = { double.class };
Method setThreshold = Agent.class.getMethod("setThreshold", args);
Method getThreshold = Agent.class.getMethod("getThreshold", null);
//Agent myClient = null;
for (int i = 0; i < 10; i++) {
//myClient.setThreshold(10 * i);
Object[] setArgs = { new Double(10) };
rr.invoke(rs, setThreshold, setArgs, setThreshold.hashCode());
//System.out.println("Threshold now " + myClient.getThreshold());
// ...
try { Thread.sleep(1000); } catch (Exception ex) { /* */ }
}