You can create an Integrated Language Environment® (ILE) COBOL or ILE RPG module that will run safely in a multithreaded environment by serializing access to the module.
You do this by specifying THREAD (SERIALIZE) on the PROCESS statement for COBOL or THREAD (*SERIALIZE) on the Control specification for RPG. When you serialize a module, only one thread can run any procedure in that module at one time. For example, consider a module that has procedures P1 and P2. If one thread is running procedure P1, no other thread can run either procedure P1 or P2 until the first thread has finished running P1. Even when a module is serialized, the COBOL or RPG programmer must ensure that global storage and heap storage are accessed in a threadsafe way. Even if an RPG or COBOL procedure apparently only uses automatic storage, RPG and COBOL use static storage control blocks in every procedure. Therefore, you must always specify THREAD (*SERIALIZE) when using ILE RPG or COBOL in a multithreaded environment.