利用互斥对象实现线程同步,并且将线程设计成一个类,但是报错了,作业。。。

源代码:
#include
#include
#include

using namespace std;

int tickets=100;
HANDLE hMutex;

class MyThread
{
private:
char name;
HANDLE hThread;
public:

MyThread(char name2)
{
    name=name2;
    hThread=CreateThread(NULL,0,FunProc,NULL,0,NULL);
}

DWORD WINAPI FunProc(LPVOID lpParameter)
{
  while (true)
  {
  WaitForSingleObject(hMutex,INFINITE);
  if (tickets>0)
  {
  printf("%c:%d",name,tickets);
  tickets=tickets-1;
  }
  else
  {
  break;
  }
  ReleaseMutex(hMutex);
  }
  return 0;
 }

~MyThread()
{
CloseHandle(hThread);
}
};

void main(){
char x,y,z;
hMutex=(HANDLE)CreateMutex(NULL,FALSE,NULL);
MyThread thread_x(x);
MyThread thread_y(y);
MyThread thread_z(z);
Sleep(5000);
}

报错是这样的:
error C3867: “MyThread::FunProc”: 函数调用缺少参数列表;请使用“&MyThread::FunProc”创建指向成员的指针

DWORD WINAPI FunProc(LPVOID lpParameter)的前面加上static,如下所示:

static DWORD WINAPI FunProc(LPVOID lpParameter)
{
...
}

函数线程必须是静态函数