mythread.cpp
来自「《windows程序设计》王艳平版的书籍源代码」· C++ 代码 · 共 64 行
CPP
64 行
///////////////////////////////////////////////////////////////
// MyThread.cpp文件
#include <stdio.h>
#include "../common/_afxwin.h"
UINT MyFunc(LPVOID lpParam)
{
printf(" Thread Identify: %d \n", AfxGetThread()->m_nThreadID);
return 0;
}
void main()
{
for(int i=0; i<10; i++)
{
AfxBeginThread(MyFunc, NULL);
}
system("pause");
}
/*
UINT MyFunc(LPVOID lpParam)
{
printf(" Thread Identify: %d \n", AfxGetThread()->m_nThreadID);
return 0;
}
void main()
{
CWinThread* pThread = AfxBeginThread (MyFunc, NULL,
THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
// pThread->m_bAutoDelete = FALSE;
pThread->ResumeThread ();
// Sometime later
DWORD dwExitCode;
::GetExitCodeThread (pThread->m_hThread, &dwExitCode);
if (dwExitCode == STILL_ACTIVE)
{
// The thread is still running.
}
else
{
// The thread has terminated. Delete the CWinThread object.
delete pThread;
}
system("pause");
}
*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?