3. Using the C++ Compiler Options
6. Creating and Using Templates
9. Improving Program Performance
10. Building Multithreaded Programs
10.1 Building Multithreaded Programs
10.1.1 Indicating Multithreaded Compilation
10.1.2 Using C++ Support Libraries With Threads and Signals
10.3 Sharing C++ Standard Library Objects Between Threads
10.4 Using Classic iostreams in a Multithreading Environment
10.4.1 Organization of the MT-Safe iostream Library
10.4.1.1 Public Conversion Routines
10.4.1.2 Compiling and Linking With the MT-Safe libC Library
10.4.1.3 MT-Safe iostream Restrictions
10.4.1.4 Reducing Performance Overhead of MT-Safe Classes
10.4.2 Interface Changes to the iostream Library
10.4.2.2 The New Class Hierarchy
10.5 Memory Barrier Intrinsics
12. Using The C++ Standard Library
13. Using the Classic iostream Library
The current exception-handling implementation is safe for multithreading; exceptions in one thread do not interfere with exceptions in other threads. However, you cannot use exceptions to communicate across threads; an exception thrown from one thread cannot be caught in another.
Each thread can set its own terminate() or unexpected() function. Calling set_terminate() or set_unexpected() in one thread affects only the exceptions in that thread. The default function for terminate() is abort() for any thread (see 8.2 Specifying Runtime Errors).
Thread cancellation through a call to pthread_cancel(3T) results in the destruction of automatic (local nonstatic) objects on the stack except when you specify -noex or -features=no%except.
pthread_cancel(3T)uses the same mechanism as exceptions. When a thread is cancelled, the execution of local destructors is interleaved with the execution of cleanup routines that the user has registered with pthread_cleanup_push(). The local objects for functions called after a particular cleanup routine is registered are destroyed before that routine is executed.