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

gotoOla

09/23/2018, 6:53 PM
When I read the article I’m thinking the the implementation of CoroutineScope is more important when you do things such as Activitys in android etc. Our microservices are strictly backend and the dependency context of the application is created once during start so we don’t typically do “new MyService()”
e

elizarov

09/23/2018, 9:13 PM
If your life-time == the whole life-time of VM, then
GlobalScope
is what you should use
g

gotoOla

09/24/2018, 7:00 AM
In this case it is since we are running the app in a container. When you say the whole life-time of the VM instead of the whole life-time of the App, does that mean that coroutines could potentially be left hanging when an app is killed? So if I run two Apps on the same JVM I shouldn’t use GloablScope?
e

elizarov

09/24/2018, 4:24 PM
Two apps on the same JVM -> don’t use
GlobalScope
.
GlobalScope
== JVM life-time. If you have multiple services in the same JVM with different life-times, then create a separate scope for each service.
3 Views