Sharing data in recursive or multithreaded programs

If your program has the RECURSIVE attribute or is compiled with the THREAD compiler option, data that is defined in the LINKAGE SECTION is not accessible on subsequent invocations of the program.

About this task

To address a record in the LINKAGE SECTION, use either of these techniques:

  • Pass an argument to the program and specify the record in an appropriate position in the USING phrase in the program.
  • Use the format-5 SET statement.

If your program has the RECURSIVE attribute or is compiled with the THREAD compiler option, the address of the record is valid for a particular instance of the program invocation. The address of the record in another execution instance of the same program must be reestablished for that execution instance. Unpredictable results will occur if you refer to a data item for which the address has not been established.

Related concepts  
Multithreading

Related references  
THREAD  
SET statement (Enterprise COBOL for z/OS® Language Reference)