VS2010环境的OpenMP的并行循环的输出问题
请教各位大牛,在VS2010中的MFC Application - Dialog based的程序,在对话框中设置了一个EDIT控件、一个BUTTON控件,
EDIT控件关联了变量名为m_editOutput。
下面的程序,输出for循环的循环变量i到EDIT控件中,在串行计算时能够正常运行:
void CTestDlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
CString strOutput;
for (int i=0;i<100;i++)
{
strOutput.Format(_T("i=%d"),i);
m_editOutput.SetWindowText(strOutput);
}
但是,如果在for语句前加上OpenMP的并行开关语句,同时设置好OpenMP的环境,成为如下:
void CTestDlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
CString strOutput;
#pragma omp parallel for
for (int i=0;i<100;i++)
{
strOutput.Format(_T("i=%d"),i);
m_editOutput.SetWindowText(strOutput);
}
则程序运行时死机了,就是闷死在那里了。
请教各位大牛,是什么原因?应该如何修改?
谢谢。