### Question:
CommandExecutingTimeout implements Timeout { @Override public synchronized void start() { if (scheduler != null) { throw new IllegalStateException("already started"); } scheduler = new Thread(delayedCommand, "Timeout"); scheduler.start(); } CommandExecutingTimeout(Runnable command, long timeout, TimeUnit unit); @Override synchronized void start(); @Override synchronized void cancel();  }### Answer:
@Test public void runs_the_command_after_the_timeout() throws InterruptedException { timeout = new CommandExecutingTimeout(new SpyCommand(), 1, TimeUnit.MILLISECONDS); timeout.start(); assertNumberOfTimeouts(1); }
@Test public void cannot_start_many_times_without_cancelling_first() throws InterruptedException { timeout = new CommandExecutingTimeout(new SpyCommand(), 10, TimeUnit.MILLISECONDS); timeout.start(); thrown.expect(IllegalStateException.class); thrown.expectMessage("already started"); timeout.start(); }