When no sharing is intended, give each thread a private copy of the data. When sharing is important, provide explicit synchronization to make certain that the program behaves in a deterministic manner.
- Thread safe – Serializable
- Thread safe – MT-Safe
An unsafe procedure can be made thread safe and serializable by surrounding it with statements to lock and unlock a mutex. Example 6–1shows three simplified implementations of fputs(), initially thread unsafe.