The WAIT statement suspends the current thread's execution until the targeted thread's execution terminates and optionally
retrieves the value returned from the targeted thread's execution.
The WAIT statement suspends execution until an event is TRUE.
General Formats for Format 1 (Thread)
General Formats for Format 2 (Event)
Syntax Rules for Format 1 (Thread)
- Thread-pointer-1 must be defined as USAGE THREAD-POINTER.
- Identifier-1 must be defined either as USAGE POINTER or must be four bytes in size. It must not be a function-identifier.
- Identifier-2 must be defined as an integer data item that has a length of at least four digits.
Syntax Rules for Format 2 (Event)
- Event-pointer-1 must be defined as USAGE EVENT-POINTER.
General Rules for Format 1 (Thread)
- Thread-pointer-1 must contain a thread handle as returned from the START statement with the IDENTIFIED BY phrase or from a
CBL_THREAD_ library routine.
- A successful WAIT statement suspends the current thread's execution until the termination of the thread referenced by the
thread handle contained in thread-pointer-1.
- If the RETURNING phrase is specified, a successful WAIT statement returns a value in identifier-1.
- After the successful execution of a WAIT statement, the thread handle contained in thread-pointer-1 is invalid.
- If the STATUS phrase is specified, the execution of the WAIT statement places into identifier-4 one of the return codes specified
for the CBL_THREAD_ library routines.
- If the WAIT statement fails, one of the return codes specified for the CBL_THREAD_ library routines is placed into identifier-2,
if specified, and then one of the following occurs:
- If the ON EXCEPTION phrase is specified, control is transferred to imperative-statement-1. Execution then continues according
to the rules for each statement specified in imperative-statement-1. If a procedure-branching or conditional statement that
causes explicit transfer of control is executed, control is transferred in accordance with the rules of that statement; otherwise,
upon completion of the execution of imperative-statement-1, control is transferred to the end of the WAIT statement and the
NOT ON EXCEPTION phrase, if specified, is ignored.
- Otherwise, if the NOT ON EXCEPTION phrase or the STATUS phrase is specified, control is transferred to the end of the WAIT
statement and the NOT ON EXCEPTION phrase, if specified, is ignored.
- Otherwise, the run unit terminates with a run-time system error.
- If the WAIT verb is successful, the following occurs in the order specified:
- If the STATUS phrase, is specified, ZERO is moved to identifier-2.
- If the NOT ON EXCEPTION phrase is specified, control is transferred to imperative-statement-2. Execution then continues according
to the rules for each statement specified in imperative-statement-2. If a procedure-branching or conditional statement that
causes explicit transfer of control is executed, control is transferred in accordance with the rules of that statement; otherwise,
upon completion of the execution of imperative-statement-2, control is transferred to the end of the WAIT statement and the
ON EXCEPTION phrase, if specified, is ignored.
General Rules for Format 2 (Event)
- A successful WAIT statement suspends execution until the event referenced by event-pointer-1 is TRUE.
Note: Execution resumes immediately if the event referenced by event-pointer-1 is TRUE when the statement is executed.
- If the WAIT statement fails, the run unit terminates with a run-time system error.