4

The Sqlite Documentation say about multithreading

1. Single-thread. In this mode, all mutexes are disabled and SQLite is unsafe to use in more than a single thread at once.

2. Multi-thread. In this mode, SQLite can be safely used by multiple threads provided that no single database connection is used simultaneously in two or more threads.

3. Serialized. In serialized mode, SQLite can be safely used by multiple threads with no restriction.

I have a question about the 1(single-thread mode ). Does this say

  1. It not allow to use sqlite3_open in two thread.

  2. It not allow to use sqlite3_open to open the same database in two thread.But use sqlite3_open to open two different database in two thread is OK.

4

1 回答 1

2

选项1。如果要选项2,则需要使用多线程模式,正如文中所说。在单线程模式下,sqlite 函数的全局状态将不受保护,在多个线程中同时使用它们将是一个问题。

使用多线程模式,您可以在同一应用程序的多个线程中使用 sqlite,但您不能同时在线程之间共享单个连接。

于 2013-06-15T20:05:22.957 回答