1. A method for handling critical sections for a speculative thread, the method operating in a system that supports a head thread that executes program instructions and the speculative thread that speculatively executes program instructions in advance of the head thread, the method comprising: during an entry into a critical section by the speculative thread, incrementing a variable containing a number of virtual locks held by the speculative thread; wherein a virtual lock held by the speculative thread is associated with the critical section and is used to keep track of the fact that the speculative thread entered the critical section; wherein the virtual lock does not prevent the speculative thread or other threads from entering the critical section; during an exit from the critical section by the speculative thread, decrementing the variable containing the number of virtual locks held by the speculative thread; receiving a request to perform a join operation with the head thread, the join operation merging state associated with the speculative thread into state associated with the head thread; and waiting to perform the join operation until the variable containing the number of virtual locks held by the speculative thread equals zero.