InterviewSolution
| 1. |
Is Sqlite Thread Safe? |
|
Answer» SQLITE is threadsafe. We make this concession since many users choose to ignore the advice given in the previous paragraph. But in order to be thread-safe, SQLite must be compiled with the SQLITE_THREADSAFE preprocessor macro set to 1. Both the Windows and Linux precompiled binaries in the distribution are compiled this way. If you are UNSURE if the SQLite library you are linking against is compiled to be threadsafe you can call the sqlite3_threadsafe() interface to find out. SQLite is threadsafe because it uses mutexes to serialize access to common data structures. However, the work of ACQUIRING and releasing these mutexes will slow SQLite down slightly. Hence, if you do not need SQLite to be threadsafe, you should DISABLE the mutexes for maximum performance. See the threading mode documentation for additional information. Under Unix, you should not carry an open SQLite database across a fork() system call into the child process. SQLite is threadsafe. We make this concession since many users choose to ignore the advice given in the previous paragraph. But in order to be thread-safe, SQLite must be compiled with the SQLITE_THREADSAFE preprocessor macro set to 1. Both the Windows and Linux precompiled binaries in the distribution are compiled this way. If you are unsure if the SQLite library you are linking against is compiled to be threadsafe you can call the sqlite3_threadsafe() interface to find out. SQLite is threadsafe because it uses mutexes to serialize access to common data structures. However, the work of acquiring and releasing these mutexes will slow SQLite down slightly. Hence, if you do not need SQLite to be threadsafe, you should disable the mutexes for maximum performance. See the threading mode documentation for additional information. Under Unix, you should not carry an open SQLite database across a fork() system call into the child process. |
|