KeyedOneThreadMutexableTaskExecutor extends KeyedOneThreadTaskExecutor<K> { public void clearAndExecute(K key, RequestResponseCommand<?> command){ MutexableOneThreadTaskExecutor oneThreadTaskExecutor = (MutexableOneThreadTaskExecutor) getOrCreate(key); oneThreadTaskExecutor.clearAndExecuteCommand(command); } KeyedOneThreadMutexableTaskExecutor(Executor executors, ScheduledExecutorService scheduled); void clearAndExecute(K key, RequestResponseCommand<?> command);  }
@Test public void testClearAndExecute() { int taskNum = 100; AtomicInteger counter = new AtomicInteger(); for (int i = 0; i < taskNum; i++) { keyed.clearAndExecute("key" + i, new CountingCommand(counter, 10)); } sleep(200); Assert.assertEquals(taskNum, counter.get()); }