KT.SLEEP_INSTEAD_OF_DELAY
Usages of 'Thread.sleep' in suspending functions and coroutine blocks
Report usages of Thread.sleep in suspending functions and coroutine blocks. A thread can contain multiple coroutines at one time due to coroutines' lightweight nature, so if one coroutine invokes Thread.sleep, it could potentially halt the execution of unrelated coroutines and cause unpredictable behavior.
Noncompliant Code
Copy
suspend fun foo() {
Thread.sleep(1_000L)
}
Compliant Code
Copy
suspend fun foo() {
delay(1_000L)
}