求大神帮忙多线程问题,我想如果对字符变量进行修改进程就结束,但是这段代码输出修改的字符然后一直输出字符a这时什么原因.?
#include <stdio.h>#include <stdlib.h>
#include <iostream>
using namespace std;
#include <windows.h>
DWORD WINAPI Fun1Proc(LPVOID lpParameter);
char tickets='a';
void main()
{
HANDLE hThread1 = NULL;
hThread1=CreateThread(NULL,0,Fun1Proc,NULL,0,NULL);
tickets = getchar();
CloseHandle(hThread1);
Sleep(4000);
}
DWORD WINAPI Fun1Proc(LPVOID lpParameter)
{
while (true)
{
if (tickets == 'a')
{
Sleep(1000);
cout<<tickets<<endl;
}
else
{
break;
}
}
return 0;
}