src/main/java/io/reactivex/internal/schedulers/NewThreadWorker.java
@NonNull
    public ScheduledRunnable scheduleActual(final Runnable run, long delayTime, @NonNull TimeUnit unit, @Nullable DisposableContainer parent) {
        Runnable decoratedRun = RxJavaPlugins.onSchedule(run);

        ScheduledRunnable sr = new ScheduledRunnable(decoratedRun, parent);

        if (parent != null) {
            if (!parent.add(sr)) {
                return sr;
            }
        }

        Future<?> f;
        try {
            if (delayTime <= 0) {
                f = executor.submit((Callable<Object>)sr);
            } else {
                f = executor.schedule((Callable<Object>)sr, delayTime, unit);
            }
            sr.setFuture(f);
        } catch (RejectedExecutionException ex) {
            if (parent != null) {
                parent.remove(sr);
            }
            RxJavaPlugins.onError(ex);
        }

        return sr;
    }
@NonNull
    public ScheduledRunnable scheduleActual(final Runnable run, long delayTime, @NonNull TimeUnit unit, @Nullable DisposableContainer parent) {
        Runnable decoratedRun = RxJavaPlugins.onSchedule(run);

        ScheduledRunnable sr = new ScheduledRunnable(decoratedRun, parent);

        if (parent != null) {
            if (!parent.add(sr)) {
                return sr;
            }
        }

        Future<?> f;
        try {
            if (delayTime <= 0) {
                f = executor.submit((Callable<Object>)sr);
            } else {
                f = executor.schedule((Callable<Object>)sr, delayTime, unit);
            }
            sr.setFuture(f);
        } catch (RejectedExecutionException ex) {
            if (parent != null) {
                parent.remove(sr);
            }
            RxJavaPlugins.onError(ex);
        }

        return sr;
    }
@ NonNull public ScheduledRunnable scheduleActual ( final Runnable run , long delayTime , @ NonNull TimeUnit unit , @ Nullable DisposableContainer parent ) { Runnable decoratedRun = RxJavaPlugins . onSchedule ( run ) ; ScheduledRunnable sr = new ScheduledRunnable ( decoratedRun , parent ) ; if ( parent != null ) { if ( ! parent . add ( sr ) ) { return sr ; } } Future < ? > f ; try { if ( delayTime <= 0 ) { f = executor . submit ( ( Callable < Object > ) sr ) ; } else { f = executor . schedule ( ( Callable < Object > ) sr , delayTime , unit ) ; } sr . setFuture ( f ) ; } catch ( RejectedExecutionException ex ) { if ( parent != null ) { parent . remove ( sr ) ; } RxJavaPlugins . onError ( ex ) ; } return sr ; }
Wraps the given runnable into a ScheduledRunnable and schedules it
on the underlying ScheduledExecutorService.
<p>If the schedule has been rejected, the ScheduledRunnable.wasScheduled will return
false.
@param run the runnable instance
@param delayTime the time to delay the execution
@param unit the time unit
@param parent the optional tracker parent to add the created ScheduledRunnable instance to before it gets scheduled
@return the ScheduledRunnable instance
Wraps the given runnable into a ScheduledRunnable and schedules it on the underlying ScheduledExecutorService . <p > If the schedule has been rejected the ScheduledRunnable . wasScheduled will return false .