-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsumer.java
More file actions
34 lines (31 loc) · 984 Bytes
/
Copy pathConsumer.java
File metadata and controls
34 lines (31 loc) · 984 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
import shared_variables.Data;
import shared_variables.Process;
import shared_variables.ProcessQueue;
public class Consumer {
public static void main(String[] args) {
Data.openConsumer();
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
Data.closeConsumer();
}
});
while (true) {
if (ProcessQueue.isEmpty()) {
try {
while (ProcessQueue.isEmpty()) {
}
} catch (Exception e) {
System.exit(-1);
}
} else {
try {
Thread.sleep(5000);
Process process = ProcessQueue.poll();
System.out.println("PID " + process.getPID() + "\tData: " + process.getData());
} catch (Exception e) {
System.exit(-1);
}
}
}
}
}