public final class BlockingScheduler
extends io.reactivex.Scheduler
Use the execute() to start waiting for tasks (from other
threads) or execute(Action) to start with a first action.
public static void main(String[] args) {
BlockingScheduler scheduler = new BlockingScheduler();
scheduler.execute(() -> {
// This executes in the blocking event loop.
// Usually the rest of the "main" method should
// be moved here.
someApi.methodCall()
.subscribeOn(Schedulers.io())
.observeOn(scheduler)
.subscribe(v -> { /* on the main thread */ });
});
}
In the example code above, observeOn(scheduler) will execute
on the main thread of the Java application.| Constructor and Description |
|---|
BlockingScheduler() |
| Modifier and Type | Method and Description |
|---|---|
io.reactivex.Scheduler.Worker |
createWorker() |
void |
execute()
Begin executing the blocking event loop without any initial action.
|
void |
execute(io.reactivex.functions.Action action)
Begin executing the blocking event loop with the given initial action
(usually contain the rest of the 'main' method).
|
io.reactivex.disposables.Disposable |
scheduleDirect(java.lang.Runnable run,
long delay,
java.util.concurrent.TimeUnit unit) |
void |
shutdown() |
public void execute()
This method will block until the shutdown() is invoked.
execute(Action)public void execute(io.reactivex.functions.Action action)
This method will block until the shutdown() is invoked.
action - the action to executepublic io.reactivex.disposables.Disposable scheduleDirect(java.lang.Runnable run,
long delay,
java.util.concurrent.TimeUnit unit)
scheduleDirect in class io.reactivex.Schedulerpublic void shutdown()
shutdown in class io.reactivex.Schedulerpublic io.reactivex.Scheduler.Worker createWorker()
createWorker in class io.reactivex.Scheduler