### 8.1 Blitz++ and thread safety ¶

To enable thread-safety in Blitz++, you need to do one of these things:

- Compile with `gcc -pthread`, or `CC -mt` under Solaris. (These options define `_REENTRANT`, which tells Blitz++ to generate thread-safe code).
- Compile with `-DBZ_THREADSAFE`, or `#define BZ_THREADSAFE` before including any Blitz++ headers.

In threadsafe mode, Blitz++ array reference counts are safeguarded by a mutex. By default, pthread mutexes are used. If you would prefer a different mutex implementation, add the appropriate `BZ_MUTEX` macros to `<blitz/blitz.h>` and send them to `blitz-dev@oonumerics.org` for incorporation.

Blitz++ does not do locking for every array element access; this would result in terrible performance. It is the job of the library user to ensure that appropriate synchronization is used.