public TcpClientPool(String host, int port, int timeout) { this.host = host; this.port = port; this.timeout = timeout; pool = new GenericObjectPool<TcpClient>(this); int coreCount = Runtime.getRuntime().availableProcessors() * 2; pool.setMaxTotal(coreCount * 2); pool.setMaxIdle(coreCount); }