forked from patniemeyer/learningjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyClientAsync.java
More file actions
39 lines (32 loc) · 992 Bytes
/
Copy pathMyClientAsync.java
File metadata and controls
39 lines (32 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.rmi.*;
import java.util.*;
public class MyClientAsync
extends java.rmi.server.UnicastRemoteObject implements WorkListener
{
public MyClientAsync(String host) throws RemoteException
{
try {
RemoteServer server = (RemoteServer)
Naming.lookup("rmi://"+host+"/NiftyServer");
StringIterator si = server.getList();
while( si.hasNext() ) {
System.out.println( si.next() );
}
server.asyncExecute( new MyCalculation(100), this );
} catch (java.io.IOException e) {
System.out.println(e);
// I/O Error or bad URL
} catch (NotBoundException e) {
System.out.println(e);
// NiftyServer isn't registered
}
}
public void workCompleted( WorkRequest request, Object result )
throws RemoteException
{
System.out.println("Async result: "+result );
}
public static void main(String [] args) throws RemoteException {
new MyClientAsync( args[0] );
}
}