struct thread_args {
int data;
};
static void *thread_func(void *arg){
struct thread_args *t_args = (struct thread_args *)arg;
printf("%d\n", t_args->data);
}
int create_thread(void){
int ret;
pthread_t tid;
struct thread_args args;
args.data = 1;
ret = pthread_create(&tid, NULL, thread_func, &args);
if (ret != 0) {
printf("Call pthread_create failed, ret %d\n", ret);
return -1;
}
return 0;
}
int data;
};
static void *thread_func(void *arg){
struct thread_args *t_args = (struct thread_args *)arg;
printf("%d\n", t_args->data);
}
int create_thread(void){
int ret;
pthread_t tid;
struct thread_args args;
args.data = 1;
ret = pthread_create(&tid, NULL, thread_func, &args);
if (ret != 0) {
printf("Call pthread_create failed, ret %d\n", ret);
return -1;
}
return 0;
}