//#include <iostream>
//#include <windows.h>
//using namespace std;
//DWORD WINAPI Fun(LPVOID lpParamter)
//
//{
// while (1) { cout << "Fun display!\n"; Sleep(1000); }
//}
//
//
//int main()
//
//{
// HANDLE hThread = CreateThread(NULL, 0, Fun, NULL, 0, NULL);
// CloseHandle(hThread);
// while (1) { cout << "main display!\n"; Sleep(2000); }
// return 0;
//}
#include <iostream>
#include <windows.h>
using namespace std;
HANDLE hMutex;
DWORD WINAPI Fun(LPVOID lpParamter)
{
while (1) {
WaitForSingleObject(hMutex, INFINITE);
cout << "Fun display!" << endl;
Sleep(1000);
ReleaseMutex(hMutex);
}
}
int main()
{
HANDLE hThread = CreateThread(NULL, 0, Fun, NULL, 0, NULL);
hMutex = CreateMutex(NULL, FALSE, "screen");
CloseHandle(hThread);
while (1) {
WaitForSingleObject(hMutex, INFINITE);
cout << "main display!" << endl;
Sleep(2000);
ReleaseMutex(hMutex);
}
return 0;
}
//#include <windows.h>
//using namespace std;
//DWORD WINAPI Fun(LPVOID lpParamter)
//
//{
// while (1) { cout << "Fun display!\n"; Sleep(1000); }
//}
//
//
//int main()
//
//{
// HANDLE hThread = CreateThread(NULL, 0, Fun, NULL, 0, NULL);
// CloseHandle(hThread);
// while (1) { cout << "main display!\n"; Sleep(2000); }
// return 0;
//}
#include <iostream>
#include <windows.h>
using namespace std;
HANDLE hMutex;
DWORD WINAPI Fun(LPVOID lpParamter)
{
while (1) {
WaitForSingleObject(hMutex, INFINITE);
cout << "Fun display!" << endl;
Sleep(1000);
ReleaseMutex(hMutex);
}
}
int main()
{
HANDLE hThread = CreateThread(NULL, 0, Fun, NULL, 0, NULL);
hMutex = CreateMutex(NULL, FALSE, "screen");
CloseHandle(hThread);
while (1) {
WaitForSingleObject(hMutex, INFINITE);
cout << "main display!" << endl;
Sleep(2000);
ReleaseMutex(hMutex);
}
return 0;
}