I'd like to see a `sleep(Duration)` method or even...
# stdlib
d
I'd like to see a
sleep(Duration)
method or even
Duration.sleep()
in Kotlin (similar to the
TimeUnit.sleep
method), instead of having to use
Thread.sleep(duration.inWholeMilliseconds)
. The less anyone has to make assumptions about the system's default time unit, the better.
j
You can use a non-blocking
delay(duration)
instead from the coroutines library
d
In my case, I'm not in a coroutine, so I'm unable to call
delay
directly.
k
Write an extension function? I personally havent had the need to sleep threads directly since using coroutines so I feel the use case might be small
1
d
I intend to add an extension method if I need it again (I just converted a Java file to Kotlin and did some
Duration
conversions, coming across the issue).