The kotlin function delay()
has this specification:
- Delays coroutine for a given time without blocking a thread and resumes it after a specified time. * This suspending function is cancellable. * If the [Job] of the current coroutine is cancelled or completed while this suspending function is waiting, this function * immediately resumes with [CancellationException].
I want to achieve exact functionality using Java. Basically, I need to run a function using some delay and this should be cancellable anytime by some given condition.
I've already gone through this thread, but most of the answers aren't quite the right fit for my scenario.