hello,all
I have a problem,I have a java process(mina tcp client), need to connect 1000+
tcp server,my code is :
connector = new NioSocketConnector();
connector.getFilterChain().addLast("clientCodec", new ProtocolCodecFilter(new
SplCodecFactory(true, type)));
connector.getSessionConfig().setReadBufferSize(MAX_READ_BUFF_SIZE);
connector.getSessionConfig().setUseReadOperation(true);
connector.setHandler(new SplClientIoHandler(this.receiver, connectorManager));
int count = 3;
while(--count >= 0){
if(count < 2){
logger.warn("retry connect count:"+count+",addr:"+addr);
}
ConnectFuture connFuture = connector.connect(addr);
connFuture.awaitUninterruptibly(CONNECT_TIMEOUT);
session = connFuture.getSession();
if(session == null){
if(count == 0){
throw new Exception("session is null!" + addr);
}
}else{
break;
}
}
connectState = ConnectState.CONNECTED;
The problem is mina created 1000+thread, So My Processor is so slow,
Are there other ways to solve it?
If I can just create a thread, with multiple objects to solve the problem? but
i don't know how to do it.
Thanks.