### Question:
SynchronizationContext implements Executor { public final ScheduledHandle schedule( final Runnable task, long delay, TimeUnit unit, ScheduledExecutorService timerService) { final ManagedRunnable runnable = new ManagedRunnable(task); ScheduledFuture<?> future = timerService.schedule(new Runnable() { @Override public void run() { execute(runnable); } @Override public String toString() { return task.toString() + "(scheduled in SynchronizationContext)"; } }, delay, unit); return new ScheduledHandle(runnable, future); } SynchronizationContext(UncaughtExceptionHandler uncaughtExceptionHandler); final void drain(); final void executeLater(Runnable runnable); @Override final void execute(Runnable task); void throwIfNotInThisSynchronizationContext(); final ScheduledHandle schedule(
      final Runnable task, long delay, TimeUnit unit, ScheduledExecutorService timerService);  }### Answer:
@Test public void schedule() { FakeClock clock = new FakeClock(); ScheduledHandle handle = syncContext.schedule(task1, 110, TimeUnit.NANOSECONDS, clock.getScheduledExecutorService()); assertThat(handle.isPending()).isTrue(); assertThat(clock.runDueTasks()).isEqualTo(0); assertThat(clock.forwardNanos(109)).isEqualTo(0); assertThat(handle.isPending()).isTrue(); verify(task1, never()).run(); assertThat(clock.forwardNanos(1)).isEqualTo(1); assertThat(handle.isPending()).isFalse(); verify(task1).run(); }
@Test public void scheduleDueImmediately() { FakeClock clock = new FakeClock(); ScheduledHandle handle = syncContext.schedule(task1, -1, TimeUnit.NANOSECONDS, clock.getScheduledExecutorService()); verify(task1, never()).run(); assertThat(handle.isPending()).isTrue(); assertThat(clock.runDueTasks()).isEqualTo(1); assertThat(handle.isPending()).isFalse(); verify(task1).run(); }