var Lock:integer; {Lock Initialization} Lock := -1; {Entering the spin lock} while InterlockedIncrement(Lock)>0 do begin Dec(Lock); Sleep(0); end; {Leaving the spin lock} Dec(Lock);