客户端的发送线程
public class S implements Runnable{
private Socket socket;
public S(Socket socket) {
this.socket = socket;
}
public void run() {
int m=10000;
for(int i=0;i<m;i++){ //发送10000次
byte[] bt = new byte[0];
            //这里的代码省略,是赋值给bt
try {
DataOutputStream netOut = new DataOutputStream(socket.getOutputStream());
if(netOut!=null&&!socket.isClosed()){
netOut.write(bt);// 客户端发送数据
netOut.flush();
}
} catch (IOException e) {
e.printStackTrace();
}
}

}
}
客户端的接收线程
public class R implements Runnable{
private Socket socket;
public R(Socket socket) {
this.socket = socket;
}
public void run() {
try {
DataInputStream netIn = new DataInputStream(socket.getInputStream());
byte buf[] = new byte[70];
if(netIn!=null&&!socket.isClosed()){
netIn.read(buf);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
测试
public class Test {
public static void main(String[] args){
try {
Socket socket = new Socket("", 0);
S s = new S(socket);
R r = new R(socket);
new Thread(s).start();
new Thread(r).start();
} catch (Exception e) {
e.printStackTrace();
}

}
}这样的代码有一个缺点,就是接收影响发送的速度,因为发送数据比较大,所以导致发送速度慢,我想问有什么办法解决?