1 #include <stdio.h>
2 #include <pthread.h>
3 #include "common_threads.h"
4
5 void *mythread(void *arg) {
6 long long int value = (long long int) arg;
7 printf("%lld\n", value);
8 return (void *) (value + 1);
9 }
10
11 int main(int argc, char *argv[]) {
12 pthread_t p;
13 long long int rvalue;
14 Pthread_create(&p, NULL, mythread, (void *) 100);
15 Pthread_join(p, (void **) &rvalue);
16 printf("returned %lld\n", rvalue);
17 return 0;
18 }
|
|
$ gcc -Wall -I../include -o thread_create_simple_args \
thread_create_simple_args.c -pthread
$ ./thread_create_simple_args
100
returned 101
$
|