Patent ID: 7610585

Claim:
A method to lock an object for a thread in a managed run-time environment comprising: determining a set of locking operations to perform on a lock corresponding to the object; performing an initial locking operation on the lock when the initial locking operation is not unbalanced, wherein the initial locking operation comprises at least one of an initial balanced synchronization of the lock or an initial optimistically balanced synchronization of the lock; and in response to the initial locking operation is active and the initial locking operation comprises the initial optimistically balanced synchronization, performing: tracking subsequent recursive optimistically balanced synchronizations of the lock without counting a number of recursive optimistically balanced synchronizations of the lock by storing a state of a pending optimistically balanced release operation corresponding to the initial optimistically balanced synchronization, and modifying the state of the pending optimistically balanced release operation corresponding to the initial optimistically balanced synchronization when a subsequent locking operation is unbalanced.