我正在尝试执行这段代码。
BOOL genFunctionOne(std::vector <char> functionOneBuffer, int functionOneCharCount)
{
int lineCountTest = 0;
int characterCountTest = 0;
for (int i = 0; i < functionOneCharCount; i++)
{
if (functionOneBuffer[i] == '\n')
lineCountTest++;
characterCountTest++;
}
return FALSE;
}
有了这个电话。
std::thread funcThreadOne( [&] { functionOne = genFunctionOne( functionBufferOne, functionCharCountOne ); } );
每次我调用该函数时。我明白了..
Microsoft Visual C++ Runtime Library
Debug Error!
Program:... my.exe
R6010
-abort() has been called
Please retry to debug the application.
断点是由... crt0msg.c 引起的
if (rterrnum != _RT_CRNL && rterrnum != _RT_BANNER && rterrnum != _RT_CRT_NOTINIT)
{
switch (_CrtDbgReportW(_CRT_ERROR, NULL, 0, NULL, L"%s", error_text))
{
case 1: _CrtDbgBreak(); msgshown = 1; break;
case 0: msgshown = 1; break;
提前致谢。
我实际上曾尝试在同一个程序中运行其他线程调用,但没有成功。可能是我的编译器,是否有任何库需要在构建选项中使用 #include 链接?
最佳答案
您是在退出作用域之前加入还是分离线程?因为你必须。线程运行调用终止的退出范围。
关于Visual Studio 2012 中的 c++ std::thread 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15423345/