夢(mèng)幻之旅

          DEBUG - 天道酬勤

             :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            671 隨筆 :: 6 文章 :: 256 評(píng)論 :: 0 Trackbacks

           

          package example.helloword.client;

          import java.util.concurrent.ExecutorService;
          import java.util.concurrent.Executors;
          import java.util.concurrent.Future;

          public class SendMsgPool
          {
              
          private static SendMsgPool sendMsgPool = new SendMsgPool();
              
              
          private ExecutorService pool;
              
              
          private SendMsgPool()
              
          {
                  pool 
          = Executors.newFixedThreadPool(3);
              }

              
              
          public static SendMsgPool getInstance()
              
          {
                  
          return sendMsgPool;
              }

              
              
          public Future<String> sendMsg(String local, int port, String msg)
              
          {
                  ClinetSocket clientScoket 
          = ClientSocketPool.getInstance()
                          .getClientSocket(local, port);
                  ClientTread ct 
          = new ClientTread(clientScoket, msg);
                  
          return pool.submit(ct);
              }

              
              
          public void shutDown()
              
          {
                  
          this.pool.shutdown();
              }

          }

           

          posted on 2011-08-30 18:01 HUIKK 閱讀(456) 評(píng)論(0)  編輯  收藏 所屬分類: Javajava Net
          主站蜘蛛池模板: 军事| 错那县| 太康县| 莲花县| 永吉县| 徐闻县| 阳谷县| 宕昌县| 扎兰屯市| 化州市| 来宾市| 江北区| 林芝县| 桃园县| 兴城市| 望谟县| 色达县| 苍梧县| 安阳县| 长垣县| 喀喇沁旗| 慈溪市| 平乡县| 韶山市| 桂林市| 福建省| 榆社县| 隆安县| 垣曲县| 黎平县| 临朐县| 洛隆县| 太康县| 张家川| 安化县| 华宁县| 吉木乃县| 汉沽区| 新余市| 邵阳县| 宿州市|