26 lines
471 B
C
26 lines
471 B
C
#include <assert.h>
|
|
#include <stdio.h>
|
|
#include <pthread.h>
|
|
|
|
typedef struct {
|
|
int a;
|
|
int b;
|
|
} myarg_t;
|
|
|
|
void *mythread(void *arg) {
|
|
myarg_t *args = (myarg_t *) arg;
|
|
printf("%d %d\n", args->a, args->b);
|
|
return NULL;
|
|
}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
pthread_t p;
|
|
myarg_t args = { 10, 20 };
|
|
|
|
int rc = pthread_create(&p, NULL, mythread, &args);
|
|
assert(rc == 0);
|
|
(void) pthread_join(p, NULL);
|
|
printf("done\n");
|
|
return 0;
|
|
}
|