Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import kotlinx.coroutines.delay
  2. import kotlinx.coroutines.launch
  3. import kotlinx.coroutines.runBlocking
  4.  
  5.  
  6. fun main(args: Array<String>) {
  7. runBlocking {
  8. repeat(1000, fun (i: Int): Unit {
  9. launch {
  10. var res = doSomething(i)
  11. print(res)
  12. }
  13. })
  14. }
  15.  
  16. print("over...")
  17. }
  18.  
  19. suspend fun doSomething(i: Int): Int {
  20. delay(100L)
  21. return i * 10
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement