lawlorslaw
02/21/2023, 6:00 PMsynchronized
block since its now deprecated in Kotlin
https://discuss.kotlinlang.org/t/replacement-for-synchronized/11240
https://chris-ribetti.medium.com/synchronized-to-reentrantlock-6f045519577e
https://proandroiddev.com/synchronization-and-thread-safety-techniques-in-java-and-kotlin-f63506370e6dgildor
02/22/2023, 2:04 AMlawlorslaw
02/22/2023, 2:57 AMgildor
02/22/2023, 3:06 AMlawlorslaw
02/22/2023, 3:14 AMval lockObject = StarPrinterManager.manager ?: Object()
synchronized(lockObject) {
// code to be executed inside the lock, to prevent multiple resources from calling this code
}
and as it stands now if the StarPrinterManager.manager
there will be a new object instance created everytime it hits that conditiongildor
02/22/2023, 3:28 AMlawlorslaw
02/22/2023, 3:29 AMgildor
02/22/2023, 3:30 AMlawlorslaw
02/22/2023, 3:31 AMgildor
02/22/2023, 3:31 AMlawlorslaw
02/22/2023, 3:32 AMgildor
02/22/2023, 3:32 AMlawlorslaw
02/22/2023, 3:32 AMgildor
02/22/2023, 3:32 AMlawlorslaw
02/22/2023, 3:41 AMgildor
02/22/2023, 4:17 AMlawlorslaw
02/22/2023, 4:29 AMgildor
02/22/2023, 4:37 AMPetr Laštovička
02/22/2023, 11:05 AMgildor
02/22/2023, 11:06 AM