Is is a good idea to use `GlobalScope` in a singl...
# announcements
r
Is is a good idea to use
GlobalScope
in a singleton class?
a
Depends on what you wanted to do, you won't be able to cancel/join jobs if you donot store their reference. Might create problem at the time of exiting the program as you don't know which jobs are finished and which are running. However you can make your own scope with a Job and dispatchers etc which seems better.
Can you show any example of such usage? Have any problem to make functions suspend instead?
r
@Animesh Sahu Thanks for the reply. A singleton will live until the application dies, so it makes no difference to use
GlobalScope
here?
a
I meant, you can't assure the jobs have been finished. If main exits, your application exits (you can't
Job.cancelAndjoin()
them)