資源簡(jiǎn)介
c++11多線程庫(kù)的使用,主要介紹了thread類中的構(gòu)造函數(shù) join函數(shù)和detach函數(shù)的使用方式
代碼片段和文件信息
#include?
#include?
using?namespace?std;
class?_tagNode
{
public:
int?a;
int?b;
};
//要執(zhí)行的函數(shù)
void?func(_tagNode&?node)
{
node.a?=?10;
node.b?=?20;
}
void?f()
{
_tagNode?node;
thread?t(func?ref(node));?//創(chuàng)建一個(gè)線程并運(yùn)行
t.j
評(píng)論
共有 條評(píng)論