RxJavaPlugins { @NonNull public static Scheduler createComputationScheduler(@NonNull ThreadFactory threadFactory) { return new ComputationScheduler(ObjectHelper.requireNonNull(threadFactory, "threadFactory is null")); } private  RxJavaPlugins(); static void lockdown(); static boolean isLockdown(); static void setFailOnNonBlockingScheduler(boolean enable); static boolean isFailOnNonBlockingScheduler(); @Nullable static Function<? super Scheduler, ? extends Scheduler> getComputationSchedulerHandler(); @Nullable static Consumer<? super Throwable> getErrorHandler(); @Nullable static Function<? super Callable<Scheduler>, ? extends Scheduler> getInitComputationSchedulerHandler(); @Nullable static Function<? super Callable<Scheduler>, ? extends Scheduler> getInitIoSchedulerHandler(); @Nullable static Function<? super Callable<Scheduler>, ? extends Scheduler> getInitNewThreadSchedulerHandler(); @Nullable static Function<? super Callable<Scheduler>, ? extends Scheduler> getInitSingleSchedulerHandler(); @Nullable static Function<? super Scheduler, ? extends Scheduler> getIoSchedulerHandler(); @Nullable static Function<? super Scheduler, ? extends Scheduler> getNewThreadSchedulerHandler(); @Nullable static Function<? super Runnable, ? extends Runnable> getScheduleHandler(); @Nullable static Function<? super Scheduler, ? extends Scheduler> getSingleSchedulerHandler(); @NonNull static Scheduler initComputationScheduler(@NonNull Callable<Scheduler> defaultScheduler); @NonNull static Scheduler initIoScheduler(@NonNull Callable<Scheduler> defaultScheduler); @NonNull static Scheduler initNewThreadScheduler(@NonNull Callable<Scheduler> defaultScheduler); @NonNull static Scheduler initSingleScheduler(@NonNull Callable<Scheduler> defaultScheduler); @NonNull static Scheduler onComputationScheduler(@NonNull Scheduler defaultScheduler); static void onError(@NonNull Throwable error); @NonNull static Scheduler onIoScheduler(@NonNull Scheduler defaultScheduler); @NonNull static Scheduler onNewThreadScheduler(@NonNull Scheduler defaultScheduler); @NonNull static Runnable onSchedule(@NonNull Runnable run); @NonNull static Scheduler onSingleScheduler(@NonNull Scheduler defaultScheduler); static void reset(); static void setComputationSchedulerHandler(@Nullable Function<? super Scheduler, ? extends Scheduler> handler); static void setErrorHandler(@Nullable Consumer<? super Throwable> handler); static void setInitComputationSchedulerHandler(@Nullable Function<? super Callable<Scheduler>, ? extends Scheduler> handler); static void setInitIoSchedulerHandler(@Nullable Function<? super Callable<Scheduler>, ? extends Scheduler> handler); static void setInitNewThreadSchedulerHandler(@Nullable Function<? super Callable<Scheduler>, ? extends Scheduler> handler); static void setInitSingleSchedulerHandler(@Nullable Function<? super Callable<Scheduler>, ? extends Scheduler> handler); static void setIoSchedulerHandler(@Nullable Function<? super Scheduler, ? extends Scheduler> handler); static void setNewThreadSchedulerHandler(@Nullable Function<? super Scheduler, ? extends Scheduler> handler); static void setScheduleHandler(@Nullable Function<? super Runnable, ? extends Runnable> handler); static void setSingleSchedulerHandler(@Nullable Function<? super Scheduler, ? extends Scheduler> handler); @Nullable static Function<? super Completable, ? extends Completable> getOnCompletableAssembly(); @Nullable static BiFunction<? super Completable, ? super CompletableObserver, ? extends CompletableObserver> getOnCompletableSubscribe(); @SuppressWarnings("rawtypes") @Nullable static Function<? super Flowable, ? extends Flowable> getOnFlowableAssembly(); @SuppressWarnings("rawtypes") @Nullable static Function<? super ConnectableFlowable, ? extends ConnectableFlowable> getOnConnectableFlowableAssembly(); @Nullable @SuppressWarnings("rawtypes") static BiFunction<? super Flowable, ? super Subscriber, ? extends Subscriber> getOnFlowableSubscribe(); @Nullable @SuppressWarnings("rawtypes") static BiFunction<? super Maybe, ? super MaybeObserver, ? extends MaybeObserver> getOnMaybeSubscribe(); @Nullable @SuppressWarnings("rawtypes") static Function<? super Maybe, ? extends Maybe> getOnMaybeAssembly(); @Nullable @SuppressWarnings("rawtypes") static Function<? super Single, ? extends Single> getOnSingleAssembly(); @Nullable @SuppressWarnings("rawtypes") static BiFunction<? super Single, ? super SingleObserver, ? extends SingleObserver> getOnSingleSubscribe(); @Nullable @SuppressWarnings("rawtypes") static Function<? super Observable, ? extends Observable> getOnObservableAssembly(); @Nullable @SuppressWarnings("rawtypes") static Function<? super ConnectableObservable, ? extends ConnectableObservable> getOnConnectableObservableAssembly(); @Nullable @SuppressWarnings("rawtypes") static BiFunction<? super Observable, ? super Observer, ? extends Observer> getOnObservableSubscribe(); static void setOnCompletableAssembly(@Nullable Function<? super Completable, ? extends Completable> onCompletableAssembly); static void setOnCompletableSubscribe(
            @Nullable BiFunction<? super Completable, ? super CompletableObserver, ? extends CompletableObserver> onCompletableSubscribe); @SuppressWarnings("rawtypes") static void setOnFlowableAssembly(@Nullable Function<? super Flowable, ? extends Flowable> onFlowableAssembly); @SuppressWarnings("rawtypes") static void setOnMaybeAssembly(@Nullable Function<? super Maybe, ? extends Maybe> onMaybeAssembly); @SuppressWarnings("rawtypes") static void setOnConnectableFlowableAssembly(@Nullable Function<? super ConnectableFlowable, ? extends ConnectableFlowable> onConnectableFlowableAssembly); @SuppressWarnings("rawtypes") static void setOnFlowableSubscribe(@Nullable BiFunction<? super Flowable, ? super Subscriber, ? extends Subscriber> onFlowableSubscribe); @SuppressWarnings("rawtypes") static void setOnMaybeSubscribe(@Nullable BiFunction<? super Maybe, MaybeObserver, ? extends MaybeObserver> onMaybeSubscribe); @SuppressWarnings("rawtypes") static void setOnObservableAssembly(@Nullable Function<? super Observable, ? extends Observable> onObservableAssembly); @SuppressWarnings("rawtypes") static void setOnConnectableObservableAssembly(@Nullable Function<? super ConnectableObservable, ? extends ConnectableObservable> onConnectableObservableAssembly); @SuppressWarnings("rawtypes") static void setOnObservableSubscribe(
            @Nullable BiFunction<? super Observable, ? super Observer, ? extends Observer> onObservableSubscribe); @SuppressWarnings("rawtypes") static void setOnSingleAssembly(@Nullable Function<? super Single, ? extends Single> onSingleAssembly); @SuppressWarnings("rawtypes") static void setOnSingleSubscribe(@Nullable BiFunction<? super Single, ? super SingleObserver, ? extends SingleObserver> onSingleSubscribe); @SuppressWarnings({ "rawtypes", "unchecked" }) @NonNull static Subscriber<? super T> onSubscribe(@NonNull Flowable<T> source, @NonNull Subscriber<? super T> subscriber); @SuppressWarnings({ "rawtypes", "unchecked" }) @NonNull static Observer<? super T> onSubscribe(@NonNull Observable<T> source, @NonNull Observer<? super T> observer); @SuppressWarnings({ "rawtypes", "unchecked" }) @NonNull static SingleObserver<? super T> onSubscribe(@NonNull Single<T> source, @NonNull SingleObserver<? super T> observer); @NonNull static CompletableObserver onSubscribe(@NonNull Completable source, @NonNull CompletableObserver observer); @SuppressWarnings({ "rawtypes", "unchecked" }) @NonNull static MaybeObserver<? super T> onSubscribe(@NonNull Maybe<T> source, @NonNull MaybeObserver<? super T> subscriber); @SuppressWarnings({ "rawtypes", "unchecked" }) @NonNull static Maybe<T> onAssembly(@NonNull Maybe<T> source); @SuppressWarnings({ "rawtypes", "unchecked" }) @NonNull static Flowable<T> onAssembly(@NonNull Flowable<T> source); @SuppressWarnings({ "rawtypes", "unchecked" }) @NonNull static ConnectableFlowable<T> onAssembly(@NonNull ConnectableFlowable<T> source); @SuppressWarnings({ "rawtypes", "unchecked" }) @NonNull static Observable<T> onAssembly(@NonNull Observable<T> source); @SuppressWarnings({ "rawtypes", "unchecked" }) @NonNull static ConnectableObservable<T> onAssembly(@NonNull ConnectableObservable<T> source); @SuppressWarnings({ "rawtypes", "unchecked" }) @NonNull static Single<T> onAssembly(@NonNull Single<T> source); @NonNull static Completable onAssembly(@NonNull Completable source); @Beta @SuppressWarnings("rawtypes") static void setOnParallelAssembly(@Nullable Function<? super ParallelFlowable, ? extends ParallelFlowable> handler); @Beta @SuppressWarnings("rawtypes") @Nullable static Function<? super ParallelFlowable, ? extends ParallelFlowable> getOnParallelAssembly(); @Beta @SuppressWarnings({ "rawtypes", "unchecked" }) @NonNull static ParallelFlowable<T> onAssembly(@NonNull ParallelFlowable<T> source); static boolean onBeforeBlocking(); static void setOnBeforeBlocking(@Nullable BooleanSupplier handler); @Nullable static BooleanSupplier getOnBeforeBlocking(); @NonNull static Scheduler createComputationScheduler(@NonNull ThreadFactory threadFactory); @NonNull static Scheduler createIoScheduler(@NonNull ThreadFactory threadFactory); @NonNull static Scheduler createNewThreadScheduler(@NonNull ThreadFactory threadFactory); @NonNull static Scheduler createSingleScheduler(@NonNull ThreadFactory threadFactory);  }
@Test public void createComputationScheduler() { final String name = "ComputationSchedulerTest"; ThreadFactory factory = new ThreadFactory() { @Override public Thread newThread(Runnable r) { return new Thread(r, name); } }; final Scheduler customScheduler = RxJavaPlugins.createComputationScheduler(factory); RxJavaPlugins.setComputationSchedulerHandler(new Function<Scheduler, Scheduler>() { @Override public Scheduler apply(Scheduler scheduler) throws Exception { return customScheduler; } }); try { verifyThread(Schedulers.computation(), name); } finally { customScheduler.shutdown(); RxJavaPlugins.reset(); } }