Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Proposal: Non-cooperative goroutine preemption. Parent comment
Of course you can. Go on, compile and run this program:
#include <pthread.h> #include <stdlib.h> void *f(void *arg) { pthread_mutex_lock((pthread_mutex_t *)arg); pthread_mutex_unlock((pthread_mutex_t *)arg); return NULL; } int main() { pthread_t threads[10000]; pthread_mutex_t mutexes[10000]; for (unsigned i = 0; i < 10000; i++) { pthread_mutex_init(&mutexes[i], NULL); pthread_mutex_lock(&mutexes[i]); pthread_create(&threads[i], NULL, f, &mutexes[i]); } for (unsigned i = 0; i < 10000; i++) pthread_mutex_unlock(&mutexes[i]); for (unsigned i = 0; i < 10000; i++) pthread_join(threads[i], NULL); return 0; }
There are no comments on this comment yet.
Of course you can. Go on, compile and run this program:
Executes in a second for me, even on macOS.