Patent attributes
A mechanism is disclosed for implementing fast synchronization of simple synchronized methods in a virtual machine. The mechanism provides for determining, during runtime, whether a set of instructions can be fully executed in lieu of invoking a synchronized method, which requires locking of a particular object. The set of instructions provides equivalent functionality to the synchronized method but with less locking overhead. In response to a determination that the set of instructions can be fully executed, the set of instructions is fully executed to achieve equivalent functionality to the synchronized method in lieu of invoking the synchronized method. In response to a determination that the set of instructions cannot be fully executed, the synchronized method is invoked. With this mechanism, simple synchronized methods can be executed with less locking overhead.