首页 > 编程语言 >c++多线程thread用法小例子

c++多线程thread用法小例子

时间:2022-11-17 12:33:24浏览次数:37  
标签:include cout thread int c++ th 多线程

测试分布式存储系统时,针对并发测试,同时创建500个文件,采用这种方法。

#include<iostream>

#include<thread>

using namespace std;

void proc(int a)

{  

  cout<<"子线程"<<endl; 创建线程。

}

int main()

{

  cout<<"主线程"<<endl;

  int a=9;

  thread th( proc , a ); 实例化,传入函数名,和函数所需要的参数。

  th.join();

  return 0;

}

标签:include,cout,thread,int,c++,th,多线程
From: https://www.cnblogs.com/chuting/p/16899075.html

相关文章