In this recipe, we are going to make use of two functions simulating long-running operations. Here is the first:
private fun `5 sec long task`() = Thread.sleep(5000)
And here is the second:
private fun `2 sec long task`() = Thread.sleep(2000)
They are both just responsible for blocking a current thread for five and two seconds, respectively, in order to simulate long-running tasks. We will also make use of the predefined function returning the current thread name for debugging purposes:
private fun getCurrentThreadName(): String = Thread.currentThread().name