THREAD
- Default
- NOTHREAD
- Recommended
- NOTHREAD
- Reasoning
The THREAD option requires additional locking in the generated code and the COBOL runtime library, which can impact performance. This is unnecessary if the program is not running in a multi-threaded environment.
This applies not just to Enterprise COBOL V6, but also applies to previous Enterprise COBOL compilers.
The THREAD option indicates that a COBOL program is to be enabled for execution in an environment that has multiple POSIX threads or PL/I tasks. In order to do so, the compiler inserts locks in various places in the generated code to protect the execution. This can impact performance of a THREAD compiled program in comparison with a corresponding NOTHREAD program.
It is recommended that the NOTHREAD option is used unless the program requires it. The compiler default is NOTHREAD.
One example where the compiler needs to insert locks to protect is I/O. When the THREAD option is used, all I/O verbs (OPEN, READ, WRITE, REWRITE, CLOSE, etc) are protected by locks. In a measurement, we observed a performance degradation of 10% due to the THREAD option.