夢幻之旅

          DEBUG - 天道酬勤

             :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            671 隨筆 :: 6 文章 :: 256 評論 :: 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 閱讀(457) 評論(0)  編輯  收藏 所屬分類: Javajava Net
          主站蜘蛛池模板: 牙克石市| 青岛市| 阳曲县| 威信县| 临邑县| 留坝县| 承德县| 涞水县| 赤壁市| 佛冈县| 全椒县| 大余县| 舒城县| 巴彦县| 锡林浩特市| 黔西县| 宣汉县| 开平市| 漳平市| 盱眙县| 壶关县| 泾阳县| 宁海县| 乐东| 防城港市| 泽州县| 商城县| 皋兰县| 乌拉特后旗| 泽普县| 甘谷县| 广水市| 张北县| 纳雍县| 手游| 正安县| 新沂市| 资中县| 雅江县| 环江| 芜湖县|