If i have this method ```fun wait(){ val timeo...
# coroutines
h
If i have this method
Copy code
fun wait(){
    val timeout= TimeHelper.getNow() + timeoutInterval // <- part of class constructor
    if(processor.getLag() > 0){
        val currentTIme = TimeHelper.getNow() 

        if(currentTime >= timeout){ System.exit(42) }
        Thread.sleep(someTime)
    }
}
And want to use a coroutine
runBlocking
and
delay
, would it be something like
Copy code
fun wait() = runBlocking{
    launch { delayMethod() }
    if(processor.getLag() > 0){
        val currentTIme = TimeHelper.getNow() 

        if(currentTime >= timeout){ System.exit(42) }
    }
}

suspend fun delayMethod(){
  delay(someTime)
}
g
No, it’s incorrect, launch returns immediately, remove launch it will suspend on someTime
so essentially delay is the same as Thread.sleep but non blocking, but requires suspend block (in your case it’s runBlocking)
but in general, it’s not very clear why have blocking function for this
wait()