💾 Archived View for thrig.me › blog › 2023 › 09 › 28 › stuckverybusy.c captured on 2023-09-28 at 16:59:07.
-=-=-=-=-=-=-
#include <err.h> #include <pthread.h> #include <unistd.h> #include <stdio.h> volatile int foo; void * busybee(void *unused) { while (1) foo++; } int main(void) { #define THC 32 pthread_t th[THC]; for (int i = 0; i < THC; i++) if (pthread_create(&th[i], NULL, busybee, NULL) != 0) err(1, "pthread_create"); while (1) sleep(99999); }