How to Create a Thread Demonstration in Win32
- 1). Open the application on which you are working in your preferred coding editor.
- 2). Type the following code:
CWinThread* AfxBeginThread( AFX_THREADPROC ThreadProc, LPVOID Param,
int nPriority = THREAD_PRIORITY_NORMAL,UINT nStackSize = 0,
DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL ); - 3). Insert, after that code, the following:
CwinThread *pThread = AfxBeginThread( ThreadFunction, &data);
UINT ThreadFunction(LPVOID param)
{
//CODE
AfxEndThread(exitCode);
return result;
} - 4). Replace "//CODE" with your thread. In this example, you have speciufied that the ThreadFunction(LPVOID param) is set to "THREAD_PRIORITY_NORMAL." To change this, amend "NORMAL" to LOW, BELOW LOW, or HIGH. Repeat this with all of your threads to demonstrate the order necessary for your application.
Source...