1.vs2012 and above, supports concurrent programming of the C++11 thread class.
Related Materials can refer to the blog: http://www.cnblogs.com/rangozhang/p/4468754.html
2. However, for the previous version, you can implement the class member function to create a child thread implementation concurrency in the following manner.
The first need to implement the thread class of the run function, it defines the thread class header file and its corresponding function implementation, concrete 1, 2 is as follows:
Figure 1 Header file for thread class
Figure 2 Implementation file for the thread class
Notice that the inherited Derivedthread class simply writes the concurrently executed function within its corresponding run () function.
It is important to note that the conditions for the end of the child thread run. The following is an example of a project to further illustrate its importance.
In the above, the class member tempgrayimg is a known input image, Tempoptmmstir is an unknown target mask image, the previous error is: The target mask image Tempoptmmstir whether the number of non-0 pixels is zero as the current child thread is the end of the flag, However, the problem is that if the current thread executes part of the target, the Tempoptmmstir mask image has a number of non-0 pixels greater than 0, but actually did not get the final target mask image, which may cause the child thread is not finished, the main thread will end hibernation early, start execution, This leads to a series of errors, the most obvious of which is the early release of the associated memory resource, causing the child threads that have not yet done so to access the related variables that have already freed the resource, and then an error occurs where the wild pointer appears (for image characterization: The image pointer is not NULL, but its length and width are zero or invalid).
Figure 3
Figure 3, from top to bottom, is the third red rectangle, which is the way to determine the end of the thread. The above two red rectangles are a way to run concurrently without a successful C + + thread class, and further research is needed later.
VS C + + concurrent programming