Hexa
11/17/2019, 10:16 AMval one = GlobalScope.async(start = CoroutineStart.LAZY) { A() }
val two = GlobalScope.async(start = CoroutineStart.LAZY) { B() }
one.start()
Thread.sleep(1000)
two.start() is there a better way to wait for one to start first before starting two without using Thread.sleep in between?spand
11/17/2019, 10:59 AMtwo to start until A() is done then you can just do one.join()spand
11/17/2019, 11:00 AMval one = GlobalScope.async() { A() }
one.join()
val two = GlobalScope.async() { B() }Hexa
11/17/2019, 11:59 AMtwo will start only after one has startedspand
11/17/2019, 12:02 PMone to signal back using a CompletableDeferred.complete that you can join on thenuli
11/17/2019, 2:12 PMuli
11/17/2019, 2:19 PMstreetsofboston
11/17/2019, 11:05 PM{ A() } to be started?
You'd need a third object that would allow your code to coordinate/synchronize the two.hallvard
11/18/2019, 7:40 AMone start two maybe? Since one should be in a good position to know exactly when `two`is to be started.uhe
11/18/2019, 9:37 AMstart = CoroutineStart.UNDISPATCHED, as Uli already said.
I don't think you can use LAZY and then start UNDISPATCHED later, though.Hexa
12/01/2019, 11:07 PMone started two like @hallvard said