# Thread safety

This library does not contain any locking code to protect objects against simultaneous modification in multi-threaded programs. Therefore it is up to you, the user of the library, to ensure that your client programs perform no conflicting operations simultaneously in multiple threads.

The reason for this is simple: there are many different threading interfaces and libpqxx does not mean to impose a choice. Additionally, locking incurs a performance overhead without benefitting most programs.

It's not all bad news, however. The library tries to avoid unsafe operations and so does the underlying libpq. Apart from a few exceptions--which should generally be noted in this documentation--all your program needs to do to maintain thread safety is to ensure that no two threads perform a non-const operation on a single object simultaneously.