simple kotlin coroutines timer with async jutsu
Code:
fun main(){
exampleAsyncAwait()
println("main thread end")
}
suspend fun calculateHardThings(startNum: String){
delay(1000)
println(startNum)
}
fun exampleAsyncAwait() = runBlocking {
val startTime = System.currentTimeMillis()
var c1:Int=1;
launch { while (c1<10){
c1++;
val deferred1 = async { calculateHardThings("tick") }
val deferred2 = async { calculateHardThings("tok") }.await()
} }
println("end")//main code thread, does not wait for the timer which is in the BackGround
}