This is an interesting program, is the use of multithreading using a variety of sorting algorithms at the same time to sort, the following is a screenshot of the main screen:
Think of this program is very simple thinking, nothing more than open 5 threads, and then each thread's entry function corresponding to a sorting algorithm, and then if the user selected is a single thread, then let these several sorting algorithms can be executed serially. But you should pay attention to a problem, how to timing. Single-threaded to say, so many threads of it. The answer lies in WaitForMultipleObjects. This should be easy to understand.
This is a word in the source program: DW = WaitForMultipleObjects (4,hthread,true, 1);
There should be no problem, that is, when all the threads are over, then it's time to calculate the end. But I am not very familiar with the timing, or to see how it timed:
struct _TIMEB timetr1;
struct _TIMEB timetr2;
time_t sec1,sec2;//global variable
Time (&SEC1);
_ftime (&TIMETR1)/time to start
_ftime (&TIMETR2);
Time (&SEC2)/Time End
Long milliseconds= (SEC2-SEC1) *1000+ (TIMETR2.MILLITM-TIMETR1.MILLITM)//Calculation time spent
time_t returns an integer time, in seconds, that requires _TIMEB to compute the millisecond time.
All right, a simpler but more interesting multithreaded routine!