<Is it always safe to just convert @Synchronized t...
# forum
r
Is it always safe to just convert @Synchronized to `Mutex.withLock`? I’m working on converting my thread-based code to coroutine-based. In many cases, I need to convert this: @Synchronized fun doSomething() { /*business logic*/ } to: private val mutex = Mutex() suspend fun doSomething() { mutex.withLock { /*business logic*/ } } However, I’m struggling to easily attain a deep understanding of Mutex. I just want to know if this is always safe. Will mutex only allow one thread at the same time in the same exact way as @Synchronized? I know Mutex...