How to do it...

Let's declare a lock() function with two arguments—an instance of the Lock interface and the function to be invoked after the lock is acquired:

inline fun performHavingLock(lock: Lock, task: () -> Unit) {
lock.lock()
try {
task()
}
finally {
lock.unlock()
}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.169.68