The THREAD-LOCAL Clause
The THREAD-LOCAL clause specifies that there is a distinct copy of a data
item or file connector for each thread entering a program.
General Format
IS THREAD-LOCAL
Syntax Rules
- The THREAD-LOCAL clause can be specified only in file description entries
or in record description entries in the Working-Storage Section.
General Rules
- If the THREAD-LOCAL clause is specified, a separate copy of the file connector
or data item is created and set to its initial state for each new thread of
execution that enters the program. The file connector or data item is only
visible to the thread causing its creation. The file connector or data item
is destroyed when the creating thread's execution terminates or when a CANCEL
statement on the program is executed; otherwise, on subsequent calls to the
program within that thread, the data item or file connector is in its last
used state.
- If the THREAD-LOCAL clause is not specified, the file connector or data item
is shared by all threads entering the program.
- In a single-threaded environment, the clause is ignored and the program behaves
exactly as if the THREAD-LOCAL clause had not been specified.