public static void main(String[] args) throws Exception { final ManagedChannel channel = new ManagedChannel() { @Override public <RequestT, ResponseT> ClientCall<RequestT, ResponseT> newCall( MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions callOptions) { return null; } @Override public String authority() { return null; } @Override public ManagedChannel shutdown() { // TODO(sduskis): Auto-generated method stub return null; } @Override public boolean isShutdown() { // TODO(sduskis): Auto-generated method stub return false; } @Override public boolean isTerminated() { // TODO(sduskis): Auto-generated method stub return false; } @Override public ManagedChannel shutdownNow() { // TODO(sduskis): Auto-generated method stub return null; } @Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { // TODO(sduskis): Auto-generated method stub return false; } }; int threads = 10; int concurrent = 400; final ChannelPool cp = new ChannelPool( Collections.<HeaderInterceptor>emptyList(), new ChannelPool.ChannelFactory() { @Override public ManagedChannel create() throws IOException { return channel; } }); cp.ensureChannelCount(40); ExecutorService es = Executors.newFixedThreadPool(threads); Callable<Void> runnable = new Callable<Void>() { @Override public Void call() throws Exception { long start = System.nanoTime(); for (int i = 0; i < TEST_COUNT; i++) { cp.newCall(null, null); } long diff = System.nanoTime() - start; double nanosPerRow = diff / TEST_COUNT; System.out.println( String.format("took %d ms. %.0f nanos/row", diff / 1_000_000, nanosPerRow)); return null; } }; runnable.call(); for (int j = 0; j < concurrent; j++) { es.submit(runnable); } es.shutdown(); es.awaitTermination(1000, TimeUnit.SECONDS); }