windows下C多线程编程用到的一些函数

来源:互联网 发布:源码查看 编辑:程序博客网 时间:2024/05/01 20:01

  • 头文件<windows.h>
  • CreateThread()--CreateThread(NULL, 0, thread2, (void *)(&i), 0, NULL); 把i的地址传给thread2函数,可供调用
  • CreateMutex()--CreateMutex(NULL, FALSE, L"mutex");
  • CreateSemaphore()--CreateSemaphore(NULL, 0, 3, L"customer")
  • WaitForSingleObject(param1,param2) param1可以是mutex,semaphore,event等等,param2是INFINITE,WAIT_TIMEOUT,WAIT_OBJECT_0,WAIT_OBANDONED
  • ReleaseMutex(Mutex)
  • ReleaseSemaphore()--ReleaseSemaphore(hCustomers, 1, NULL); 相当于up操作的+1
  • Sleep(param) param是毫秒数
  • CloseHandle(HANDLE)

0 0