There are three general approaches to making code thread safe, the first of which is to write reentrant code. If you only use local variables stored on the stack then restarting the function with ...