It is absolutely safe. Coroutine machinery guarantees that execution is
sequential (i.e. non-concurrent), despite being spread over different threads. The definition of sequential execution includes visibility of writes/puts. In more technical terms, the execution before suspension point always
happens-before execution after suspension point. If you are interested in implementation details, it is actually not the machinery itself, but the contract of
CompletableFuture.whenComplete
method (which is used to implement
await
) that provides the corresponding
happens-before edge.