The body is under VC, and the MFC Console program default behavior is a single-threaded working environment. We can use the following two ways to change the single-thread in its working environment to multi-threaded. 1. In the Code Generation option under Engineering -> Settings -> C / C , set Use Run-Time Library to Multithreaded (Multithread). 2, you can add "/ MT" in the current Project Options. (Represents C runtime library using multi-threaded version)
#include
F.Open ("w.txt", iOS :: app); f << (lpctstr) str-< endl; str.format ("% d / n", INU); Printf ("% s", str) ; Sleep (1000); INU ; f.close ();}}
INT main () {handle hthread; // Returned thread handle, I want to end the thread early, can pass the handle DWORD thREADID; // Record the thread ID number int inu; hthread = CreateThread (Null, 0, (lpthread_start_routine) Readtime, NULL , 0, & threadid; for (int i = 0; i <1000; i ) for (int J = 0; i <10000; j ) {SLEEP (1000);} return 0;}
You need to load the header file (AFX.H) of the class used so that the MFC class-independent of the GUI can be used. In this example, CString is used.