diff --git a/day7/homework/h6.c b/day7/homework/h6.c index c74be24..224478c 100644 --- a/day7/homework/h6.c +++ b/day7/homework/h6.c @@ -7,7 +7,7 @@ #include #include -pthread_mutex_t mutux = PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; typedef struct node { @@ -21,7 +21,7 @@ void *find(void *data) { int n = 0; // 标识待查询内容在链表中的索引号 char *name = (char *)data; - pthread_mutex_lock(&mutux); + pthread_mutex_lock(&mutex); // 查询 Node *p = head->next; while (p != NULL) @@ -29,7 +29,7 @@ void *find(void *data) if (strcmp(p->name, name) == 0) { printf("%s 在链表的索引为 %d\n", name, n); - pthread_mutex_unlock(&mutux); + pthread_mutex_unlock(&mutex); return NULL; } @@ -38,7 +38,7 @@ void *find(void *data) p = p->next; } printf("%s 在链表中未找到\n", name); - pthread_mutex_unlock(&mutux); + pthread_mutex_unlock(&mutex); return NULL; } @@ -89,5 +89,7 @@ int main(int argc, char const *argv[]) pthread_join(t[i], NULL); } + pthread_mutex_destroy(&mutex); + return 0; }