views:

179

answers:

1

Hi,

I am using sqlite in my iPhone app.

I have some database operations, in which I have to insert into two tables different data(means there is no data-dependency). Can I perform these two operations in seperate thread. While the insert operation in each table are more than one. So I am doing this in a while loop also.

+2  A: 

SQLite itself can be built to be thread-safe (for v3.3.1 or later, if it is compiled with SQLITE_THREADSAFE defined). You can verify this by calling sqlite_threadsafe().

I suggest you read the following carefully:

Even if SQLite is thread-safe, you may wish to revisit your design. Having multiple threads write to the database is probably not ideal, and it may be possible to redesign to avoid the requirement altogether.

gavinb