正如标题所述:是否可以在另一个线程中运行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/