@Test public void testSameKey(){ TestCommand command1 = new TestCommand("success", sleepInterval); TestCommand command2 = new TestCommand("success", sleepInterval); keyed.execute("key1", command1); keyed.execute("key1", command2); sleep(sleepInterval/2); Assert.assertTrue(command1.isBeginExecute()); Assert.assertFalse(command2.isBeginExecute()); }
public void execute(K key, Command<?> command){ OneThreadTaskExecutor oneThreadTaskExecutor = getOrCreate(key); oneThreadTaskExecutor.executeCommand(command); }
KeyedOneThreadTaskExecutor implements Destroyable { public void execute(K key, Command<?> command){ OneThreadTaskExecutor oneThreadTaskExecutor = getOrCreate(key); oneThreadTaskExecutor.executeCommand(command); } }
KeyedOneThreadTaskExecutor implements Destroyable { public void execute(K key, Command<?> command){ OneThreadTaskExecutor oneThreadTaskExecutor = getOrCreate(key); oneThreadTaskExecutor.executeCommand(command); } KeyedOneThreadTaskExecutor(Executor executors); }
KeyedOneThreadTaskExecutor implements Destroyable { public void execute(K key, Command<?> command){ OneThreadTaskExecutor oneThreadTaskExecutor = getOrCreate(key); oneThreadTaskExecutor.executeCommand(command); } KeyedOneThreadTaskExecutor(Executor executors); void execute(K key, Command<?> command); @Override void destroy(); }
KeyedOneThreadTaskExecutor implements Destroyable { public void execute(K key, Command<?> command){ OneThreadTaskExecutor oneThreadTaskExecutor = getOrCreate(key); oneThreadTaskExecutor.executeCommand(command); } KeyedOneThreadTaskExecutor(Executor executors); void execute(K key, Command<?> command); @Override void destroy();  }