synchronized

expect inline fun <T> synchronized(lock: SynchronizedObject, block: () -> T): T

Executes the given block of code within a synchronized block, using the specified SynchronizedObject as the synchronization object. This function simplifies the process of creating synchronized blocks safely.

Usage:

val syncObject = SynchronizedObject()
synchronized(syncObject) {
// Critical section of code
}
actual inline fun <T> synchronized(lock: SynchronizedObject, block: () -> T): T

Executes the given block of code within a synchronized block, using the specified SynchronizedObject as the synchronization object. This function simplifies the process of creating synchronized blocks safely.

Usage:

val syncObject = SynchronizedObject()
synchronized(syncObject) {
// Critical section of code
}