首页 > 试题广场 >

在一个空闲的多核环境下,以下c++代码运行时间为?(精确到秒

[单选题]
在一个空闲的多核环境下,以下c++代码运行时间为?(精确到秒) #include <iostream>
#include <future>
#include <thread>
using namespace std::literals::chrono_literals;
void foo(int n) { std::this_thread::sleep_for(n * 1s); }
int main(){
std::async( std::launch::async, foo, 10 );
std::async( std::launch::async, foo, 5 );
return 0;
}
  • 5s
  • 10s
  • 15s
  • 10s或者15s

这道题你会答吗?花几分钟告诉大家答案吧!