📄 complexclient.java
字号:
package socket;
import java.net.*;
import java.util.Date;
import java.io.*;
public class ComplexClient extends Thread{
public static void main(String args[]){
ComplexClient[] m=new ComplexClient[10];
for(int i=0;i<10;i++){
m[i]=new ComplexClient();
m[i].setName("client"+i);
m[i].start();
}
}
public void run() {
int c;
Socket s1;
OutputStream out;
PrintStream ps;
try{
// Open your connection to sunbert, at port 5432
s1 = new Socket("127.0.0.1",5435);
// Get an input file handle from the socket and read the input
out = s1.getOutputStream();
ps = new PrintStream(out,true);
for(int i=0;i<100;i++){
ps.println(getName()+ ":"+ new Date().toString());
sleep(100);
}//end for
ps.close();
s1.close();
}catch(Exception e){}
} //end of method go()
} //end of class ComplexClient()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -