You can specify that a multi-threaded program is to be reentrant by compiling it with the REENTRANT Compiler directive. You should use reentrant programs for most (if not all) of the modules in a multi-threaded application.
If you specify REENTRANT(1), all compiler-generated temporary work areas are allocated on a per-thread basis. All user data and FD file areas allocated in the Environment and Data Divisions are shared by all threads. It is the responsibility of the programmer to ensure serialization to the program's data by use of the CBL_ synchronization calls.
If you specify REENTRANT(2), all Working-Storage Section and File Section data, as well as system work areas, are allocated on a per-thread basis. Local storage is allocated dynamically on the stack. This eliminates thread contention on these areas, so that the program behaves safely if called from multiple threads concurrently. No program locking or unlocking is needed. The disadvantage with this Compiler directive setting is that there is no data shared (other than any data defined as EXTERNAL) between the threads.
REENTRANT(2) is a quick and simple way of getting a program running in a multi-threaded application, but you should aim to compile with REENTRANT(1).
A reentrant program must itself resolve all possible contention on data items in its Working-Storage Section and File Section. One or more of the techniques for resolving data contention must be used to accomplish this; see the next section for details.