随手写

#include <iostream>
#include <windows.h>
using namespace std;
void main()
{
    cout<<"OK"<<endl;
    while(TRUE)
    {
        HANDLE hMutex = ::CreateMutex(NULL, FALSE, "Mutex");
        WaitForSingleObject(hMutex, INFINITE);
        cout<<"in"<<endl;
        Sleep(2000);
        cout<<"out"<<endl;
        ReleaseMutex(hMutex);
    }
}

posted @ 2009-07-28 12:07  dzqabc  阅读(179)  评论(0编辑  收藏  举报