some thread API examples
This commit is contained in:
19
threads-api/thread_create_simple_args.c
Normal file
19
threads-api/thread_create_simple_args.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include "common_threads.h"
|
||||
|
||||
void *mythread(void *arg) {
|
||||
long long int value = (long long int) arg;
|
||||
printf("%lld\n", value);
|
||||
return (void *) (value + 1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
pthread_t p;
|
||||
long long int rvalue;
|
||||
Pthread_create(&p, NULL, mythread, (void *) 100);
|
||||
Pthread_join(p, (void **) &rvalue);
|
||||
printf("returned %lld\n", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user