Milan Vadhel
09/24/2021, 10:38 AMCLOVIS
09/24/2021, 10:46 AMwhile (true) {
doStuff()
delay(5000)
}
?Milan Vadhel
09/24/2021, 11:02 AMfun main(array : Array<String>){
val job = repeatFun()
job.start()
}
fun repeatFun(): Job {
val coroutineScope = CoroutineScope(Dispatchers.Default)
return coroutineScope.launch {
while(isActive) {
println("Hello")
delay(5000)
}
}
}
I have did something like this but it is not printing anything.CLOVIS
09/24/2021, 12:17 PMsuspend fun main() {
// Your code here
delay(100000)
}
That will workCLOVIS
09/24/2021, 12:18 PMstart
.Milan Vadhel
09/24/2021, 12:22 PMCLOVIS
09/24/2021, 12:24 PMmain
, it gets killed.CLOVIS
09/24/2021, 12:26 PMsuspend fun main() {
val job = GlobalScope.launch {
delay(1000)
println("This will never be printed")
}
println("This is printed, then the program dies")
}
suspend fun main() {
val job = GlobalScope.launch {
delay(1000)
println("This is printed after 1 second")
}.join()
}
Colton Idle
09/24/2021, 11:49 PM