Kotlin flow execution issue

Viewed 73

I'm studying Kotlin and I have a question about the flow execution of the language. I wrote this code into the Kotlin playground:

fun main() {
   println("Hello,") 
   Thread.sleep(5000L) 
   print("World!")
}

I expected that the program prints "Hello,", then "World!" after 5 seconds (e.g. how it works in Java). However, it prints "Hello, World!" after 5 seconds and nothing before. Am I missing something? I've also tried to insert System.out.flush() after the first print but it didn't work.

Thanks

1 Answers
Related