Rational Developer for System z
Enterprise COBOL for z/OS, Version 4.1, Programming Guide


Serializing file access with multithreading

To take full advantage of automatic serialization and to avoid explicitly writing your own serialization logic, use one of the recommended file organizations and usage patterns when you access files in threaded programs.

Use one of the following file organizations:

Use the following pattern for input:

  OPEN INPUT fn
  . . .
  READ fn INTO local-storage-item
  . . .
* Process the record from the local-storage item
  . . .
  CLOSE fn  

Use the following pattern for output:

  OPEN OUTPUT fn
  . . .
* Construct output record in local-storage item
  . . .
  WRITE rec FROM local-storage-item
  . . .
  CLOSE fn

With other usage patterns, you must take one of the following actions:

To avoid serialization problems when you access a file from multiple threads, define the data items that are associated with the file (such as file-status data items and key arguments) in the LOCAL-STORAGE SECTION.

Example: usage patterns of file input and output with multithreading

related tasks  
Calling UNIX/POSIX APIs


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)