开发者

"Unhandled exception" error when using a loop inside thread

开发者 https://www.devze.com 2022-12-24 04:50 出处:网络
I got this error Unhandled exception at 0x0049b946 in Program.exe: 0xC0000005: Access violation reading location 0x00000090.

I got this error

Unhandled exception at 0x0049b946 in Program.exe: 0xC0000005: Access violation reading location 0x00000090.

and the error points to this line:

        // thread.hpp ln 56
        void run()
        {
            f(); // here <<
        }

When trying to run this code:

void frameFunc()
{
    for(;;)
    {
         开发者_如何学C//..........do something. it is too long to paste. (calculations)
    }
}

int main()
{
   boost::thread framethread(frameFunc);
   framethread.join();
   //........
}

The error will simply gone when I remove the loop in frameFunc.

Any kind of help would be appreciated :)


The code that you showed looks valid. I think the problem is inside the code that is not shown.

0

精彩评论

暂无评论...
验证码 换一张
取 消