Function calls that are not thread safe

Your multithreaded application at times requires access to functions or system services that are not thread safe. There are few completely safe alternatives for calling these functions.

To illustrate the alternatives, consider the example of a program that calls API foo(). Because function foo() is listed as not being thread safe, you need to find a safe way to call it. Two common options are using a global mutual exclusion (mutex) or using a separate job to run the function that is not thread safe.

Related concepts
Thread safety
Synchronization techniques among threads
One-time initialization and thread safety
Common multithreaded programming errors
Related reference
CL commands and thread safety
Threads considerations for ILE COBOL and RPG language