@Test public void signallyATaskCompleteFreesUpAThread() { threadPool = new ActionThreadPool("Test Action", 2); final List<String> resultList = new CopyOnWriteArrayList<>(); Runnable action = new Runnable() { @Override public void run() { resultList.add(Thread.currentThread().getName()); } }; threadPool.execute(action); threadPool.execute(action); threadPool.execute(action); while (resultList.size() != 3) { } }
@Override public void execute(Runnable action) { ThreadManager nextThread = pool.pollFirst(); boolean submitted = nextThread.submit(action); pool.add(nextThread); if (!submitted) { throw new RejectedExecutionException(); } }
ActionThreadPool implements Executor { @Override public void execute(Runnable action) { ThreadManager nextThread = pool.pollFirst(); boolean submitted = nextThread.submit(action); pool.add(nextThread); if (!submitted) { throw new RejectedExecutionException(); } } }
ActionThreadPool implements Executor { @Override public void execute(Runnable action) { ThreadManager nextThread = pool.pollFirst(); boolean submitted = nextThread.submit(action); pool.add(nextThread); if (!submitted) { throw new RejectedExecutionException(); } } ActionThreadPool(String actionName, int threadCount); }
ActionThreadPool implements Executor { @Override public void execute(Runnable action) { ThreadManager nextThread = pool.pollFirst(); boolean submitted = nextThread.submit(action); pool.add(nextThread); if (!submitted) { throw new RejectedExecutionException(); } } ActionThreadPool(String actionName, int threadCount); @Override void execute(Runnable action); void signalTaskComplete(ThreadManager threadManager); void shutdown(); }
ActionThreadPool implements Executor { @Override public void execute(Runnable action) { ThreadManager nextThread = pool.pollFirst(); boolean submitted = nextThread.submit(action); pool.add(nextThread); if (!submitted) { throw new RejectedExecutionException(); } } ActionThreadPool(String actionName, int threadCount); @Override void execute(Runnable action); void signalTaskComplete(ThreadManager threadManager); void shutdown();  }