Visual Studio 2012中的c ++ std :: thread问题

Lig*_*eep 3 c++ debugging multithreading visual-studio-2012

我正在尝试执行此代码.

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;     
}
Run Code Online (Sandbox Code Playgroud)

通过这个电话.

std::thread funcThreadOne( [&] { functionOne = genFunctionOne( functionBufferOne, functionCharCountOne ); } );
Run Code Online (Sandbox Code Playgroud)

每次我调用这个函数.我明白了..

Microsoft Visual C++ Runtime Library

Debug Error!

Program:... my.exe

R6010
-abort() has been called

Please retry to debug the application.
Run Code Online (Sandbox Code Playgroud)

断点由... 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;
Run Code Online (Sandbox Code Playgroud)

提前致谢.

我实际上试图在同一个程序中运行其他线程调用,但没有运气.它可能是我的编译器,是否有任何库需要在构建选项中与#include链接?

coo*_*451 12

在退出范围之前是否加入或分离线程?因为你必须这样做.使用线程运行的退出范围调用terminate.