Patent ID: 8176491

Claim:
A machine implemented process for fast synchronization, comprising: detecting, during compile time, an invocation of a synchronized method in a set of code; accessing, during compile time, preregistered substitute code for the synchronized method, wherein the substitute code is different than the set of code; generating, during compile time, a set of instructions using the substitute code; producing, during compile time, a set of conditional invocation instructions for conditionally invoking the synchronized method; determining, during runtime, whether the set of instructions can be fully executed in lieu of invoking the synchronized method, wherein the synchronized method requires locking of a particular object, wherein determining that the set of instructions can be fully executed in lieu of invoking the synchronized method comprises: determining whether a set of one or more conditions for the conditional invocation instructions are met, and determining that the particular object is not locked, wherein the set of instructions is being executed by a current thread, wherein one of the conditions in the set of conditions is whether the particular object is currently locked after a thread scheduler lock, which prevents all other threads from being scheduled, is obtained, wherein if the particular object is currently locked, then it is determined that the set of instructions cannot be fully executed in lieu of invoking the synchronized method, and wherein the set of instructions provides equivalent functionality to the synchronized method with less locking overhead than the synchronized method; in response to a determination that the set of instructions can be fully executed in lieu of invoking the synchronized method, fully executing the set of instructions to achieve equivalent functionality to the synchronized method, and foregoing invocation of the synchronized method without locking the particular object; and in response to a determination that the set of instructions cannot be fully executed in lieu of invoking the synchronized method, invoking the synchronized method.