@Test public void test() throws InterruptedException { NodeContext ctx = new NodeContext(Executors.newFixedThreadPool(10), new BusinessHandler() { private AtomicInteger counter = new AtomicInteger(); @Override public Response exec(Request request) { R r = (R) request; System.out.println(r); System.out.println(counter.incrementAndGet()); return null; } }); for (int i = 0; i < 1000000; i++) { ctx.put(new R(i)); } }
public void put(Request request) throws InterruptedException { Node node = new Node(executor, new NodeCallable(handler, request)); queue.put(node); }
NodeContext { public void put(Request request) throws InterruptedException { Node node = new Node(executor, new NodeCallable(handler, request)); queue.put(node); } }
NodeContext { public void put(Request request) throws InterruptedException { Node node = new Node(executor, new NodeCallable(handler, request)); queue.put(node); } NodeContext(ExecutorService executor, BusinessHandler handler ); }
NodeContext { public void put(Request request) throws InterruptedException { Node node = new Node(executor, new NodeCallable(handler, request)); queue.put(node); } NodeContext(ExecutorService executor, BusinessHandler handler ); void put(Request request); }
NodeContext { public void put(Request request) throws InterruptedException { Node node = new Node(executor, new NodeCallable(handler, request)); queue.put(node); } NodeContext(ExecutorService executor, BusinessHandler handler ); void put(Request request);  }