-
Notifications
You must be signed in to change notification settings - Fork 1
/
Reader.java
executable file
·45 lines (44 loc) · 1.07 KB
/
Reader.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
import java.rmi.*;
import java.util.*;
public class Reader{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n;
System.out.println("Enter your id (1/2):");
n = sc.nextInt();
try{
Distributed stub=(Distributed)Naming.lookup("rmi://localhost:5000/run");
Thread newThread = new Thread(() -> {
try{
stub.readingControl(n,"start");
} catch(Exception e){
System.out.println(e);
}
});
newThread.start();
while(true) {
System.out.println("Do you want to (pause) or type anything to (stop) ?");
String s = sc.next();
if(s.equals("pause")) {
stub.readingControl(n,"pause");
System.out.println("Do you want to (resume) or type anything to (stop)");
s = sc.next();
if(s.equals("resume"))
stub.readingControl(n,"resume");
else
{
stub.readingControl(n,"stop");
break;
}
}
else
{
stub.readingControl(n,"stop");
break;
}
}
} catch(Exception e){
System.out.println(e);
}
}
}