The LOCK THREAD statement prevents other threads from running.
- The LOCK THREAD statement prevents other threads from running. The thread that executes the LOCK statement is the only thread
allowed to run until an UNLOCK THREAD statement is executed, or the thread terminates. Locking a thread ensures that other
threads will not modify a critical piece of data or other shared resource.
- A thread can be locked multiple times. Each time a thread executes a LOCK THREAD statement, the number of locks held by the
thread increases by one. In order to unlock a thread with multiple locks, an equal number of UNLOCK THREAD statements must
This allows a thread to lock itself, call a subroutine that also locks itself, and remain locked when that subroutines unlocks
itself. See UNLOCK THREAD.