暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

main-race.c 321B

123456789101112131415161718
  1. #include <stdio.h>
  2. #include "mythreads.h"
  3. int balance = 0;
  4. void* worker(void* arg) {
  5. balance++; // unprotected access
  6. return NULL;
  7. }
  8. int main(int argc, char *argv[]) {
  9. pthread_t p;
  10. Pthread_create(&p, NULL, worker, NULL);
  11. balance++; // unprotected access
  12. Pthread_join(p, NULL);
  13. return 0;
  14. }