Function calls that are not threadsafe

Multithreaded application at times requires access to functions or system services that are not threadsafe. 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 the function foo() is listed as not threadsafe, you must 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 threadsafe.