First page Back Continue Last page Overview Graphics

RLock

Rlock is a reentrant lock object. A reentrant lock must be released by the thread that acquired it. Once a thread has acquired a reentrant lock, the same thread may acquire it again without blocking; the thread must release it once for each time it has acquired it.

Difference between Lock and Rlock:

A Lock can only be acquired once. It has to be released, before it can be acquired again.

An RLock can be acquired multiple times by the same thread. To be unlocked it needs to be released the same number of times it has been acquired.

An acquired Lock can be released by any thread, while an acquired RLock can only be released by the thread which acquired it.