option D; use a single connection per thread. Take advantage of __thread ... and each thread can see if( !database_connection ) connect().
-or- make A thread that you queue all work to; but you'd still need a seperate connection for each reader... Open and close are a large hit to do per operation. if you don't have Thread-Local-Storage, you can make a container structure that contains the therad id (pthread_self()) and the connection. On Thu, May 29, 2014 at 9:38 PM, techi eth <[email protected]> wrote: > What is the best practice to use sqlite3 handler in multithread > environment.[I am using on Linux] > > > > · Open sqlite3 database file once & use the same sqlite3 handler in > all the thread for any operation on sqlite3 database file. > > or > > · Open & close all the time for each operation on sqlite3 database > file. > > Thanks > _______________________________________________ > sqlite-users mailing list > [email protected] > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

