On Mon, Oct 04, 2010 at 07:25:05PM -0700, Dustin Sallings scratched on the wall: > > On Oct 4, 2010, at 14:46, Jay A. Kreibich wrote: > > > If you're treating the threads independently, each with their own > > database connections, you should be safe with =2 ("multithread"). > > That provides less protection than =1 ("serialized"), but it is also > > faster. Continued from above: > > > > When compiled with SQLITE_THREADSAFE=2, SQLite can be used in a > > multithreaded program so long as no two threads attempt to use > > the same database connection at the same time. > > > I did read that, but I didn't quite understand what the global state > is that will be accessed between otherwise independent threads. > Reading the code makes that a bit more clear.
The main difference between =1 and =2 is that =2 assumes you more or less know what you're doing and will either lock a database handle as you pass it between threads or you'll keep it private to a thread. =1 is designed to be more or less idiot proof, and will simply not let you do something stupid with a database handle, like have two threads try to execute two different statements at the same time. Either way, any multi-threaded program requires something other than =0. In your case, it sounds like =2 would be sufficient, but if you're not looking for every millisecond of performance you can find, the default =1 might be easier and safer. -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Intelligence is like underwear: it is important that you have it, but showing it to the wrong people has the tendency to make them feel uncomfortable." -- Angela Johnson _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users