pBuf=this->m_Data;
bool bSleep;
for(int i=0;i
pDlg->m_pSemaphoreFull->Lock();
pDlg->m_pMutex->Lock();
sprintf(pBuf,pDlg->m_sBuf);
bSleep=pDlg->m_bSlow ;
pDlg->m_pMutex->Unlock();
pBuf+=10;
if(pBuf>m_Data+CSM_BUF_COUNT-10)
pBuf=m_Data;
m_Data[CSM_BUF_COUNT]=0;
pDlg->m_pMutex->Lock();
sprintf(pDlg->m_sBufCSM.GetBuffer(CSM_BUF_COUNT+10),m_Data);
pDlg->m_pMutex->Unlock();
if (bSleep)
Sleep(100);
pDlg->m_pSemaphoreEmpty ->Unlock();
}
return CWinThread::Run();
}
///////////////////////////////////////
3启动线程:
///////////////////////////////////////
m_pSemaphoreFull =new CSemaphore(1,1);
m_pSemaphoreEmpty =new CSemaphore(0,1);
m_pMutex =new CMutex;
this->m_bUpdateAuto =false;
this->m_pProducerThread =new CProducerThread(this);
this->m_pConsumerThread =new CConsumerThread(this);
this->m_sBuf.Format("1234567890");
this->UpdateData(false);
this->m_pProducerThread->CreateThread(CREATE_SUSPENDED);
VERIFY(m_pProducerThread->SetThreadPriority(THREAD_PRIORITY_IDLE));
this->m_pConsumerThread->CreateThread(CREATE_SUSPENDED);
VERIFY(m_pConsumerThread->SetThreadPriority(THREAD_PRIORITY_IDLE));
this->m_pProducerThread->ResumeThread();
this->m_pConsumerThread->ResumeThread();静态页面:http://www.qqread.com/vc/i320575020.html进入讨论组讨论。
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询



