mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00

PR-URL: https://github.com/nodejs/node/pull/57214 Reviewed-By: Guy Bedford <guybedford@gmail.com>
24 lines
391 B
C
24 lines
391 B
C
#include <assert.h>
|
|
#include <pthread.h>
|
|
#include <unistd.h>
|
|
|
|
void* worker(void* data) {
|
|
int* result = (int*) data;
|
|
sleep(1);
|
|
*result = 42;
|
|
return NULL;
|
|
}
|
|
|
|
int main() {
|
|
pthread_t thread = NULL;
|
|
int result = 0;
|
|
|
|
int r = pthread_create(&thread, NULL, worker, &result);
|
|
assert(r == 0);
|
|
|
|
r = pthread_join(thread, NULL);
|
|
assert(r == 0);
|
|
|
|
assert(result == 42);
|
|
return 0;
|
|
}
|