public static ScheduledFuture < ? > schedule ( Runnable runnable , Duration runFrequency , TimerType timerType ) { switch ( timerType ) { case OneTimeRun : return executor . schedule ( runnable , runFrequency . toMillis ( ) , TimeUnit . MILLISECONDS ) ; case RepeatRun : return executor . scheduleWithFixedDelay ( runnable , runFrequency . toMillis ( ) , runFrequency . toMillis ( ) , TimeUnit . MILLISECONDS ) ; default : throw new UnsupportedOperationException ( "Unsupported timer pattern." ) ; } }
runFrequency implemented only for TimeUnit granularity - Seconds