-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path9.3.6.java
More file actions
62 lines (52 loc) · 1.26 KB
/
Copy path9.3.6.java
File metadata and controls
62 lines (52 loc) · 1.26 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
interface R extends Remote{
public void m() throws RemoteException;
public void n() throws RemoteException;
}
class RImpl extends UnicastRemoteObject implements{
boolean condizione=false;
RImpl() throws RemoteException;
public void m() throws RemoteException{
try{
synchronized(this){
while(condizione==false){
wait();
}
}
}catch(Exception e){}
}
public void n() throws RemoteException{
try{
synchronized(this){
condizione=true;
notify();
}
}
catch(Exception e){}
}
}
/*SERVER*/
public void main(String[]a){
public void main(String []a){
R r=new Rimpl();
Naming.rebind("pippo",a);
}
}
/*CLIENT*/
public void main(String[]a){
private boolean cond=false;
public void main(String []a){
R r=(R) Naming.lookup("pippo");
new Thread{
public void run(){
r.m();
cond=true;
}
}.start();
new Thread{
public void run(){
while(!cond)
r.n();
}
}.start();
}
}