Patent ID: 7975271

Claim:
A method comprising: determining that a thread desires a lock for accessing a resource that is sequentially divided into a plurality of portions; dynamically determining a portion of the resource for which the lock is to be obtained for the thread by: attempting, by the thread, trylock on a first portion of the resource; and attempting, by the thread, the trylock on another portion of the resource when the trylock on the first portion of the resource is unsuccessful, wherein the another portion is a next portion following the first portion in a designated sequence of the plurality of portions of the resource that is sequentially divided; and obtaining the lock on the determined portion; if determined that the thread has attempted the trylock on each of the plurality of portions of the resource without a successful use, forcing a lock on a forced portion of the resource and the thread using the forced portion of the resource for which the lock is obtained for performing a desired operation; wherein the forced portion is a portion for which trylock was previously unsuccessful.