#define _AFXDLL
#include <afxmt.h>
#include <iostream>
using namespace std;

CCriticalSection critical;
int tick=0;


DWORD WINAPI Func1(LPVOID lpParam);
DWORD __stdcall Func1(LPVOID lpParam)
{
critical.Lock();
tick += 10;
cout << "Func1 TICK NOW IS : " << tick << endl;
critical.Unlock();
return 0;
}


DWORD WINAPI Func2(LPVOID lpParam);
DWORD __stdcall Func2(LPVOID lpParam)
{
critical.Lock();
tick += 10;
cout << "Func2 TICK NOW IS : " << tick << endl;
critical.Unlock();
return 0;
}

int main()
{
HANDLE t1 = CreateThread(NULL, 0, Func1, NULL, 0, NULL);
HANDLE t2 = CreateThread(NULL, 0, Func2, NULL, 0, NULL);

while (true)
{

}

CloseHandle(t1);
CloseHandle(t2);
return 0;
}