Untitled
unknown
plain_text
a year ago
771 B
2
Indexable
Never
#include <iostream> #include <thread> #include <time.h> using namespace std; void func1() { cout<<"Call func 1 "<<endl; for (int i=0;i<10;i++) { cout<<"func 1 : "<<i<<endl; } cout<<"ENd func 1"<<endl; } void func2() { cout<<"Call func 2 "<<endl; for (int i=0;i<10;i++) { cout<<"func 2 : "<<i<<endl; } cout<<"ENd func 2"<<endl; } int main() { clock_t begin = clock(); thread f1(func1); thread f2(func2); if (f1.joinable()) { f2.join(); } if (f2.joinable()) { f1.join(); } clock_t end = clock(); //ghi lại thời gian lúc sau cout<<"Time run: "<<(float)(end-begin)/CLOCKS_PER_SEC<<" s"<<endl; return 0; }