标签:style http color os 使用 io java ar for
final TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
final TCPNIOTransport transport = builder.build();
final TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
final TCPNIOTransport transport = builder.build();
try {
// Bind server socket and start transport
transport.bind(12345);
transport.start();
System.out.println("Press <enter> to exit...");
System.in.read();
} catch(Exception e){
e.printStackTrace();
}
final TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
final TCPNIOTransport transport = builder.build();
Future<Connection> fc = transport.connect("127.0.0.1", 12345);
Connection conn = fc.get();
conn.write(message);
IOStrategy | 这个之前有讲解基本有如下几个:
|
memoryManager | 这个就是内存管理器:有Heap和ByteBuffer两种。 |
processor |
这个一般设置FilterChain,我们可以在FilterChain里面添加自己的滤镜,用于处理消息 |
readBufferSize | 读数据流的分配内存大小 |
writeBuffersSize | 写数据流的内存分配大小,一般可以根据工程而配置。 |
final TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
final ThreadPoolConfig config = builder.getWorkerThreadPoolConfig();
config.setCorePoolSize(5).setMaxPoolSize(5).setQueueLimit(-1);
final TCPNIOTransport transport = builder.build();
queue | 任务队列 |
queueLimit | 队列最大容纳的数量 |
threadFactory | 线程工厂,用于创建Worker线程或其他线程。。。 |
poolName | 线程池的名称 |
priority | The priority to be assigned to each thread. This will override any priority assigned by the specified ThreadFactory. |
corePoolSize | 初始线程数 |
maxPoolSize | 最大线程数,-1表示无限大 |
keepAliveTime | The maximum time a thread may stay idle and wait for a new task to execute before it will be released. Custom time units can be used. |
transactionTimeout | The maximum time a thread may be allowed to run a single task before interrupt signal will be sent. Custom time units can be used. |
标签:style http color os 使用 io java ar for
原文地址:http://www.cnblogs.com/chzcb/p/3946346.html