Skip to content

Instantly share code, notes, and snippets.

@brownsoo
Created August 13, 2021 05:32
Show Gist options
  • Save brownsoo/9038498eb1406ac019e5ac30e6bef8c9 to your computer and use it in GitHub Desktop.
Save brownsoo/9038498eb1406ac019e5ac30e6bef8c9 to your computer and use it in GitHub Desktop.
Canceling an Action
Scheduler scheduler = Schedulers.newThread();
Scheduler.Worker worker = scheduler.createWorker();
worker.schedule(() -> {
result += "First_Action";
worker.unsubscribe();
});
worker.schedule(() -> result += "Second_Action");
Assert.assertTrue(result.equals("First_Action"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment