`
j0hnny
  • 浏览: 2743 次
  • 性别: Icon_minigender_1
最近访客 更多访客>>
社区版块
存档分类
最新评论
文章列表
服务端: public class MultiServerPool { private ServerSocket serverSocket; private ExecutorService pool;// 线程池 private final int POOL_SIZE = 10;// 单个CPU线程池大小 public void service() { try { serverSocket = new ServerSocket(2046); // Runtime的availableProcessor()方法返回当前系统的CPU数目. pool ...
服务端: 实现Runnable接口: public class MultiServerRunnable { private ServerSocket server; public void service() { try { server = new ServerSocket(2046); while (true) { Socket client = server.accept(); Thread thread = new Thread(new Handler(client)); thread.start(); ...

简单Socket

服务端: public class ServerSide { public void service() { ServerSocket server = null; Socket client = null; BufferedReader is = null; PrintWriter os = null; try { server = new ServerSocket(2046); System.out.println("服务器启动..."); client = server.accept(); ...
Global site tag (gtag.js) - Google Analytics