objective-c - 是否可以在另一个线程上运行 sqlite3_exec() ?

标签 objective-c sqlite

正如标题所述:是否可以在另一个线程中运行sqlite3_exec()方法?

TBXMLSuccessBlock sBlock = ^(TBXML *tbxmlDocument) {
    xmlArray = [NSMutableArray array];

    if (tbxmlDocument.rootXMLElement)
        [self fillArrayWithXmlContents:tbxmlDocument.rootXMLElement];

    for (int i = 0; i < xmlArray.Count; i++)
        sqlite3_exec(db, "Query that uses xmlArray values", 0, 0, 0);
};

正如您所看到的,这是一个正在另一个线程上执行的 block 。

最佳答案

我建议您引用sqlite3 FAQ :

Is SQLite threadsafe?

Threads are evil. Avoid them.

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. blah blah blah

所以我会说"is",应该没问题。

关于objective-c - 是否可以在另一个线程上运行 sqlite3_exec() ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18588022/

相关文章:

iphone - 如何在 iPhone 应用更新时更新 SQLite 数据库?

android sqlite 日期范围

objective-c - Cocoa中如何从子类委托(delegate)方法调用父类(super class)委托(delegate)方法?

objective-c - 跨类访问 NSApplicationDelegate 方法

ios - 当我使用 HTTP API 进行搜索时,我应该如何重新加载 searchResults TableView ?

android - 查询两个日期之间的记录持续时间

c# - Linq to EF guid in where 子句总是返回 null

iphone - 在 plist 中处理持久 boolean 值的最佳方法?

iphone - Ipad/iphone..操作表

android - 适用于 Android Xamarin 的 SQlCipher