MF 

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.
Restriction: THREAD-LOCAL cannot be used in class programs compiled for managed code (but can be used in procedural COBOL programs compiled to managed code).

General Format

IS THREAD-LOCAL 

Syntax Rules

  1. The THREAD-LOCAL clause can be specified only in file description entries or in record description entries in the Working-Storage Section.
  2. For JVM COBOL applications, data items cannot be object references.

General Rules

  1. 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.
  2. If the THREAD-LOCAL clause is not specified, the file connector or data item is shared by all threads entering the program.
  3. In a single-threaded environment, the clause is ignored and the program behaves exactly as if the THREAD-LOCAL clause had not been specified.