梦幻之旅

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 阅读(437) 评论(0)  编辑  收藏 所属分类: Javajava Net

只有注册用户登录后才能发表评论。


网站导航: