The locked directive allows methods to be declared implicitly thread safe. The compiler will automatically generate the proper calls to Monitor surrounding the method body.
method DoItSafely; locked;
Declaring a method as "locked" is basically equivalent to surrounding the entire method body with a "locking" statement:
locking self do begin ... end;
In version 3, it's possible to enter the object to lock a method, property or event on. The syntax for this is:
method DoItSafely; locked on fLockObject;
See the Microsoft documentation on Monitor Class for further information regarding locking. Their docs state:
"The Monitor class controls access to objects by granting a lock for an object to a single thread. Object locks provide the ability to restrict access to a block of code, commonly called a critical section. While a thread owns the lock for an object, no other thread can acquire that lock. You can also use Monitor to ensure that no other thread is allowed to access a section of application code being executed by the lock owner, unless the other thread is executing the code using a different locked object."