mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
Clean up some of the threading code
This commit is contained in:
parent
0547eabcd6
commit
9f963dc597
62 changed files with 175 additions and 582 deletions
33
examples/thread.c
Normal file
33
examples/thread.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
#if 0
|
||||
/*─────────────────────────────────────────────────────────────────╗
|
||||
│ To the extent possible under law, Justine Tunney has waived │
|
||||
│ all copyright and related or neighboring rights to this file, │
|
||||
│ as it is written in the following disclaimers: │
|
||||
│ • http://unlicense.org/ │
|
||||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/intrin/pthread.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
/**
|
||||
* @fileoverview Basic POSIX Threads Example.
|
||||
*
|
||||
* $ make -j8 o//examples/thread.com
|
||||
* $ o//examples/thread.com
|
||||
* hi there
|
||||
*
|
||||
*/
|
||||
|
||||
void *worker(void *arg) {
|
||||
fputs(arg, stdout);
|
||||
return "there\n";
|
||||
}
|
||||
|
||||
int main() {
|
||||
void *result;
|
||||
pthread_t id;
|
||||
pthread_create(&id, 0, worker, "hi ");
|
||||
pthread_join(id, &result);
|
||||
fputs(result, stdout);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue