Thread usage

A majority of today's applications are using some database. In many cases, such applications usually ran from different PCs, with simultaneous read/write operations. The following example will demonstrate threads using the MySQL database.

Getting ready

For our next example, you will need to install the MySQL C connector. A detailed explanation can be found in the Appendix. After the successful installation of the MySQL C connector, start Visual Studio.

How to do it...

  1. Create a new C++ Console application. Name it MultithreadedDBTest.
  2. Open Solution explorer and add a new header file. Name it CMySQL.h. Open CMySQL.h and paste the following code:
    #include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <mysql.h> class CMySQL { public: ...

Get C++ Multithreading Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.