Sharing files between threads

All files are shared between threads.

If a thread (other than MAIN) opens a file, it must be closed before that thread terminates.

A file opened in a MAIN thread is not closed until it is explicitly closed or the program ends. Except for the Language Environment message file on z/OS, if you do not serialize your file usage, you might get unpredictable results, possibly including abends.

Serialization is the responsibility of the user. See Sharing data between threads.

The message file and the display statement are automatically serialized by PL/I.