C: Minimal pthread mutex Beispiel
English
Deutsch
pthread_example.c
#include <pthread.h>
int main() {
// Mutex erstellen
pthread_mutex_t mutex;
pthread_mutex_init(&mutex, NULL /* Standard-Mutex-Attribute */);
// Sperren
pthread_mutex_lock(&mutex);
// Entsperren
pthread_mutex_unlock(&mutex);
// Aufräumen
pthread_mutex_destroy(&mutex);
}So kompilieren Sie:
compile_pthread.sh
gcc -o main main.c -pthreadCheck out similar posts by category:
C/C++
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow