-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteThread.java
More file actions
42 lines (35 loc) · 783 Bytes
/
WriteThread.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
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Queue;
public class WriteThread extends Thread{
private OutputStream out;
private Queue<String> qout;
public WriteThread(OutputStream out,Queue<String> qout){
this.out=out;
this.qout=qout;
}
public void run(){
String value=null;
DataOutputStream dout= new DataOutputStream(out);
while(true){
if(!qout.isEmpty())
{
value=qout.poll();
//value=453;
try {
dout.writeUTF(value);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
WriteThread.sleep(1);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}//¸ô50ms¼àÌýÒ»´Î
}
}