update
This commit is contained in:
20
concurrency/concurrency_v1/chapter1/1_helloworld.cpp
Normal file
20
concurrency/concurrency_v1/chapter1/1_helloworld.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// Created by light on 19-11-5.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void hello() {
|
||||
cout << "hello world" << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
thread t(hello);
|
||||
t.join(); // must add this line otherwise will failed!
|
||||
// 需要注意的是线程对象执行了join后就不再joinable了,所以只能调用join一次。
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user