@Test public void testStartMtimes() { int times = 50; CommandFuture<Void> future = new DefaultCommandFuture<>(); when(command.execute()).thenReturn(future); future.setSuccess(); for (int i = 0; i < times; i++) { oneThreadTaskExecutor.executeCommand(command); sleep(30); verify(command, times(i + 1)).execute(); } }
public void executeCommand(Command<?> command) { logger.debug("[executeCommand][offer it in pool]{}", command); boolean offer = false; synchronized (this) { offer = tasks.offer(command); } if (!offer) { throw new IllegalStateException("pool full:" + tasks.size()); } doExecute(); }
OneThreadTaskExecutor implements Destroyable { public void executeCommand(Command<?> command) { logger.debug("[executeCommand][offer it in pool]{}", command); boolean offer = false; synchronized (this) { offer = tasks.offer(command); } if (!offer) { throw new IllegalStateException("pool full:" + tasks.size()); } doExecute(); } }
OneThreadTaskExecutor implements Destroyable { public void executeCommand(Command<?> command) { logger.debug("[executeCommand][offer it in pool]{}", command); boolean offer = false; synchronized (this) { offer = tasks.offer(command); } if (!offer) { throw new IllegalStateException("pool full:" + tasks.size()); } doExecute(); } OneThreadTaskExecutor(Executor executors);  OneThreadTaskExecutor(RetryCommandFactory<?> retryCommandFactory, Executor executors); }
OneThreadTaskExecutor implements Destroyable { public void executeCommand(Command<?> command) { logger.debug("[executeCommand][offer it in pool]{}", command); boolean offer = false; synchronized (this) { offer = tasks.offer(command); } if (!offer) { throw new IllegalStateException("pool full:" + tasks.size()); } doExecute(); } OneThreadTaskExecutor(Executor executors);  OneThreadTaskExecutor(RetryCommandFactory<?> retryCommandFactory, Executor executors); void executeCommand(Command<?> command); @Override void destroy(); }
OneThreadTaskExecutor implements Destroyable { public void executeCommand(Command<?> command) { logger.debug("[executeCommand][offer it in pool]{}", command); boolean offer = false; synchronized (this) { offer = tasks.offer(command); } if (!offer) { throw new IllegalStateException("pool full:" + tasks.size()); } doExecute(); } OneThreadTaskExecutor(Executor executors);  OneThreadTaskExecutor(RetryCommandFactory<?> retryCommandFactory, Executor executors); void executeCommand(Command<?> command); @Override void destroy();  }