Concurrent access with threads
I have a SQLite database. I want to write unit tests to verify the behavior of the database during a concurrent access. How can I use threads to make a concurrent access?
did you read this article about concurrency with Qt? http://qt-project.org/doc/qt-5.0/qtcore/thread-basics.html
Qt classes does not support multithreaded access to SQL databases, unfortunately: http://qt-project.org/doc/qt-5/threads-modules.html#threads-and-the-sql-module
If you still want to use concurrent access, you can use Qt to create threads, and then use the native SQLite API to do reading.
However, note that SQLite already has built-in read/write locks that are rigorously tested (See Q5 and Q6 at https://sqlite.org/faq.html ). Do you need to test it yourself?
[quote author="Xander84" date="1396465160"]did you read this article about concurrency with Qt? http://qt-project.org/doc/qt-5.0/qtcore/thread-basics.html[/quote]That link is outdated and incomplete. For generic info about multithreading in Qt, see these instead:
- http://qt-project.org/doc/qt-5/threads.html (recommended)
(Please provide links to the latest version of the documentation -- the Qt 5.0 documentation has many issues)
I'm back. I explain you what I wante to do. I'm new in threads.
Here's what I want:
@I want to create a Unit test that simulate the concurrent access. So I want to creat 2 unit test: one insert data into a table "TOTO" and an other insert data to the same table at the same moment. How can I implement and run at the same moment my unit tests? Please Jus an example.@