- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadThread.java
More file actions
Latest commit
38 lines (29 loc) · 644 Bytes
/
Copy pathReadThread.java
File metadata and controls
38 lines (29 loc) · 644 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
35
36
37
38
importjava.io.*;
importjava.util.Queue;
publicclassReadThreadextendsThread{
privateInputStreamin;
privateQueue<String> qin;
publicReadThread(InputStreamin,Queue<String> qin){
this.in=in;
this.qin=qin;
}
publicvoidrun(){
Stringvalue=null;
DataInputStreamdin =newDataInputStream(in);
while(true){
try {
value=din.readUTF();
} catch (IOExceptione) {
// TODO Auto-generated catch block
e.printStackTrace();
}
qin.add(value);
try {
Thread.sleep(1);
} catch (InterruptedExceptione) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}