O'Reilly logo

C++ Multithreading Cookbook by Milos Ljumovic

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required