为什么在使用多线程时没有打印

问题描述

我是初学者。在VS代码中尝试了一个简单的多线程代码。什么都没有打印。试过 cout.flush() 仍然没有。除了当我尝试使用多线程时,一切正常。

#include <iostream>
#include <thread> 
using namespace std;

void hello(){

    cout<<"Hello World"<<endl;
}

int main(){

    cout<<"Test"<<endl;
    thread t1(hello);
    t1.join();

    return 0;
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)