- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteThread.java
More file actions
Latest commit
42 lines (35 loc) · 783 Bytes
/
Copy pathWriteThread.java
File metadata and controls
42 lines (35 loc) · 783 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
39
40
41
importjava.io.DataOutputStream;
importjava.io.IOException;
importjava.io.OutputStream;
importjava.util.Queue;
publicclassWriteThreadextendsThread{
privateOutputStreamout;
privateQueue<String> qout;
publicWriteThread(OutputStreamout,Queue<String> qout){
this.out=out;
this.qout=qout;
}
publicvoidrun(){
Stringvalue=null;
DataOutputStreamdout= newDataOutputStream(out);
while(true){
if(!qout.isEmpty())
{
value=qout.poll();
//value=453;
try {
dout.writeUTF(value);
} catch (IOExceptione) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
WriteThread.sleep(1);
} catch (InterruptedExceptione) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}//¸ô50ms¼àÌýÒ»´Î
}
}