```// assuming this is a singleton private val def...
# coroutines
c
Copy code
// assuming this is a singleton
private val deferredThing: Deferred<Thing> =
      ioScope.async(start = CoroutineStart.LAZY) {
        createThing()
      }
Are there guarantees that this block will only run a single time, no matter how many times it’s awaited / which threads call await?
y
Yes!
d
Another option to consider is
Copy code
private val deferredThing: Deferred<Thing> by lazy {
  ioScope.async {
    createThing()
  }
}
This way, if
deferredThing
is never used,
ioScope
won't even learn about its existence, + it's using the more general mechanism, applicable in more contexts.
c
yeah actually i was doing that initially but was thinking that synchronization by lazy and coroutines would be some sort of anti-pattern (I guess not đŸ¤· ) FWIW — this thing is always going to get used
y
If it's always gonna get used, why not just launch it immediately? no need for
lazy
or
LAZY
then
c
it’s an android app and i want to spread out the work instead of jamming up application start (re dagger init)