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

标签 c++ multithreading debugging 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;     
}

有了这个电话。

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/

相关文章:

c - 在不平衡树上拆分 OpenMP 线程

java - Eclipse 无法启动调试方式

c# - 异常后C#中局部变量的值?

c++ - 使用 c++0x - 安全吗?

c++ - 如何使用 boost 库反序列化和获取成员值

c++ - Qt 中的长线

iphone - iOS 如何在没有堆栈跟踪的情况下调试崩溃,如 : [__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array?

c++ - 如何在 C++ 中通过引用传递数组元素?

multithreading - 在 Akka Actors 中阻止调用

java - 覆盖同步锁中使用的变量是否会阻止其垃圾回收?