thread.c程序pthread_create函数第三个参数为线程函数的起始地址,文中并无add函数,源代码如下:

wKiom1SaiH_BoPKlAADUU3OTYJ8972.jpg

thread.c编译时会报未声明错误:

wKiom1SajCTCUDHBAAE0_xQ4Rqs094.jpg

根据语境推测应该是count,替换如下:

wKiom1SajYLBhAM4AADBIuTlF24768.jpg

重新编译,gcc编译时在最后加参数-lpthread,否则编译报对

pthread_create和pthread_join未定义的引用如下:

wKiom1SajP6DI8G3AAFTRGH58Ps468.jpg

应当是行末最后加入-lpthread编译,正确编译命令:

gcc -lpthread thread.c -o main

thread.go程序无z变量,应当是counter:

wKioL1SalIbhm5-iAABZir4h82A627.jpg