package socket;import java.io.*;import java.net.Socket;public class SocketClient {public static void main(String[] args) throws InterruptedException {ClientThread[] threads = new ClientThread[200];for (int i = 0; i < threads.length; i++) {ClientThread clientThread = new ClientThread();clientThread.setName("user-test-" + (int)Math.random()*1000);threads[i] = clientThread;}for (ClientThread thread : threads) {thread.run();thread.join();}System.out.println("所有线程执行完毕");// try {// Socket socket = new Socket("localhost", 8088);// // 待发送的消息// OutputStream outputStream = socket.getOutputStream();// PrintWriter printWriter = new PrintWriter(outputStream);// printWriter.write("我是请求方,我来给你发消息了");// printWriter.flush();// // 断开连接// socket.shutdownOutput();// // 从服务器接收的信息// InputStream is = socket.getInputStream();// BufferedReader br = new BufferedReader(new InputStreamReader(is));// String info = null;// while ((info = br.readLine()) != null) {// System.out.println("我是客户端,接收到服务器返回的信息:" + info);// }// br.close();// is.close();// outputStream.close();// socket.close();//// } catch (IOException e) {// e.printStackTrace();// }}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。