thread.c程序pthread_create函數第三個參數爲線程函數的起始地址,文中並沒有add函數,源代碼以下:ide
![2014-12-24 16:56:36 的屏幕截圖.png wKiom1SaiH_BoPKlAADUU3OTYJ8972.jpg](http://static.javashuo.com/static/loading.gif)
thread.c編譯時會報未聲明錯誤:函數
![2014-12-24 17:49:04 的屏幕截圖.png wKiom1SajCTCUDHBAAE0_xQ4Rqs094.jpg](http://static.javashuo.com/static/loading.gif)
根據語境推測應該是count,替換以下:spa
![2014-12-24 17:55:00 的屏幕截圖.png wKiom1SajYLBhAM4AADBIuTlF24768.jpg](http://static.javashuo.com/static/loading.gif)
從新編譯,gcc編譯時在最後加參數-lpthread,不然編譯報對線程
pthread_create和pthread_join未定義的引用以下:blog
![2014-12-24 17:52:50 的屏幕截圖.png wKiom1SajP6DI8G3AAFTRGH58Ps468.jpg](http://static.javashuo.com/static/loading.gif)
應當是行末最後加入-lpthread編譯,正確編譯命令:get
gcc -lpthread thread.c -o mainit
thread.go程序無z變量,應當是counter:io
![2014-12-24 18:20:22 的屏幕截圖.png wKioL1SalIbhm5-iAABZir4h82A627.jpg](http://static.javashuo.com/static/loading.gif)