I am trying to download files from multiple reposi...
# coroutines
y
I am trying to download files from multiple repositories by calling a suspend function(downloadFile). I provide a mapOf(repo, index) and call the downloadFile inside an async. How to ensure that downloadFile is threadsafe?
b
it depends on which dispatcher you run this code. If it is multithreaded dispatcher (Default/IO, etc), downloadFile will be called concurrently. If you don't want this, just don't use async/await, and map them sequentially. Worths noting, concurrent access to downloadFile is not necessarily bad - we don't see the code inside, it might be perfectly fine.
y
thanks