-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathServer214.java
75 lines (58 loc) · 1.08 KB
/
Server214.java
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
63
64
65
66
67
68
69
70
71
72
73
74
75
//2014-01-07
interface I extends Remote{
public void f()throws RemoteException;
public void g()throws RemoteException;
}
public class IImpl extends UnicastRemoteObject implements I{
public synchronized void f()throws RemoteException{
for(int i=0;i<5;i++)
System.Out.println("FF");
}
public void g()throws RemoteException{
for(int i=0;i<5;i++)
System.Out.println("GG");
}
}
public class S{
public static void main(String[] a){
IImpl u= new IImpl();
Naming.rebind("ui",u);
}
}
public class C1{
public void m(String s){
for(int i=0;i<5;i++)
System.Out.println(s);
}
public static void main(String[] a){
IImpl u= Naming.lookup("ui");
class T1 extends Thread{
public void run(){
synchronized(u){
m("A");
u.f();
m("B");
}
}
}
class T2 extends Thread{
public void run(){
synchronized(u){
m("UNO");
u.g();
m("DUE");
}
}
}
T1 t1=new T1();
T2 t2=new T2();
t1.start();
t2.start();
}
}
public class C2{
public static void main(String[] a){
IImpl u= Naming.lookup("ui");
u.f();
}
}