https://kotlinlang.org logo
#coroutines
Title
# coroutines
w

WukongRework.exe

11/07/2020, 2:23 AM
hey, i was just wondering, is there a way to tell two separate coroutines to wait a specific time before continuing without having to cancelling them and then relaunching once both coroutines are done
e

ephemient

11/07/2020, 3:14 AM
do you want something like a rendezvous barrier? https://en.wikipedia.org/wiki/Barrier_(computer_science)
I don't think there's anything like this built-in but it's not difficult to make https://pl.kotl.in/TrH0zzsfI
w

WukongRework.exe

11/07/2020, 4:16 AM
thanks so much this is exactly what i was looking for!
e

elizarov

11/07/2020, 10:33 AM
Coroutines are cheap. Usually, you don’t need things like barriers that you have to use with (expensive) threads. Instead of having two coroutines to wait on a barrier you can simply launch two new coroutines after delay or whatever other action you were doing.
3 Views