1、.cc文件下的睡眠函數:
this_thread::sleep_for(chrono::seconds(1));睡眠1秒
2、eg: g++ multithread.cc -o multithread -std=c++11 -lpthread
-std=C++11 :表示采用C++11標准
-lpthread :表示 線程庫。
3、用thread創建線程
4、join()的作用:阻塞主線程。
5、線程函數帶參數
6、使用Linux計算兩時間戳間的時間:
1 struct timeval start_time,end_time; 2 gettimeofday(&start_time,NULL); 3 double time_used=end_time.tv_sec-start_time.tv_sec+(end_time.tv_usec-start_time.tv_usec)/1000000.0;