Two or more threads can access the same storage if any of the following
are true:
Variables are defined with the STATIC(*ALLTHREAD) keyword
EXPORT/IMPORT keywords are used on the definition specifications in a
thread-serialized module
Data is based on a pointer where the pointer is available to more than
one module
Files are created or overridden with SHARE(*YES). In this case, it is
the feedback areas that represent the shared storage. RPG always refers to
the feedback areas during file operations, so you should synchronize access
to the file itself.
It is up to the programmer to handle thread safety for storage that is
shared across modules. This is done by adding logic in the application to
synchronize access to the storage. To synchronize access to this shared storage,
you can do one or both of the following:
Structure the application such that the shared resources are not accessed
simultaneously from multiple threads.
If you are going to access resources simultaneously from separate threads,
synchronize access using facilities such as semaphores or mutexes. For more
information, see Using thread-related APIs.