我在对话框类中定义了一个结构数组
struct PetArray
{
DWORD lPId;
char * Name; //名字

};

PetArray Pet[20];
         CCriticalSection  m_cs;
         int Count;在对话框类里面定义一个线程函数:
UINT CBabyServerDlg::DataReadThreadProc(LPVOID pParam)
{

   
CBabyServerDlg *pDlg=(CBabyServerDlg *)pParam;
pDlg->m_cs.Lock();

pDlg->Pet[pDlg->Count].Name="线程开始了";
pDlg->m_cs.Unlock();
if (pParam==NULL)
AfxEndThread(NULL); return 0;
}
在对话框的一个按钮事件中开始20个线程操作
....
for(i=0;i<20;i++)
{
AfxBeginThread(DataReadThreadProc,this,THREAD_PRIORITY_NORMAL);
}
......
for( i=0;i<Count-1;i++)
{

OutString(Pet[i].Name );//在这里就会出错了,这个函数没错,是往对话框的一个list控件中输出字符串的 }
请问为什么在进程里调数组数据的时候就会出访问冲突错误呢?应该怎么改啊