[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


3.2.2 Thread-Safe

A routine is called thread-safe if it can be called simultaneously from multiple threads without risk of corruption. Generally this means that it does some simple level of locking (possibly using the DECthreads global lock) to prevent simultaneously active calls in different threads. See Section 3.2.3.1 for information about the global lock.

Although these routines are thread-safe, they may be inefficient. For example, a UNIX stdio package that is thread-safe might still block all threads in the process while waiting to read or write data to a file. Routines such as localtime(3) or strtok(), which traditionally rely on static storage, could be made thread-safe by using thread-specific data instead of static variables.