-
Notifications
You must be signed in to change notification settings - Fork 0
/
PublicIn.java
46 lines (33 loc) · 860 Bytes
/
PublicIn.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
package CarlaSocket;
import java.io.BufferedReader;
import java.util.Deque;
/* A class to handle all the msgs from the server to Jason
* (C) University of Aberdeen - Hilal Al Shukairi
*/
public class PublicIn extends Thread{
private volatile Deque<String> q_server_to_jason;
private volatile BufferedReader in;
public boolean stop = false;
public PublicIn(Deque<String> q_server_to_jason, BufferedReader in) {
System.out.println("Start public in");
this.q_server_to_jason = q_server_to_jason;
this.in = in;
}
@Override
public void run() {
while (!this.stop) {
if (this.in != null) {
String s;
try {
while((s = this.in.readLine()) != null) {
this.q_server_to_jason.add(s);
}
break;
} catch (Exception e) {
if (!this.stop) break;
}
}
}
System.out.println("[Stop] public in");
}
}