File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
app/src/main/java/com/lukaslechner/coroutineusecasesonandroid/playground/fundamentals Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.lukaslechner.coroutineusecasesonandroid.playground.fundamentals
2
+
3
+ import android.os.Handler
4
+ import android.os.Looper
5
+ import kotlinx.coroutines.async
6
+ import kotlinx.coroutines.joinAll
7
+ import kotlinx.coroutines.runBlocking
8
+
9
+ fun main () = runBlocking {
10
+ println (" main starts" )
11
+ joinAll(
12
+ async { delayDemonstration(1 , 500 ) },
13
+ async { delayDemonstration(2 , 300 ) }
14
+ )
15
+ println (" main ends" )
16
+ }
17
+
18
+ suspend fun delayDemonstration (number : Int , delay : Long ) {
19
+ println (" Coroutine $number starts work" )
20
+
21
+ // delay(delay)
22
+
23
+ Handler (Looper .getMainLooper())
24
+ .postDelayed({
25
+ println (" Coroutine $number has finished" )
26
+ }, 500 )
27
+ }
You can’t perform that action at this time.
0 commit comments