#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <iostream>
using namespace std;
typedef struct thread_info { /* Used as argument to thread_start() */
pthread_t thread_id; /* ID returned by pthread_create() */
int thread_num; /* Application-defined thread # */
char* argv_string; /* From command-line argument */
}INFO_T;
void* start_routine (void* arg)
{
//cout << ((INFO_T*)arg)->thread_num << endl;
cout << *(int *)arg << endl;
cout << "new thread" << endl;
}
int main()
{
//INFO_T* tinfo;
//tinfo->thread_num = 5;
int num = 5;
pthread_t tid;
int ret=pthread_create(&tid, NULL,start_routine,&num);
if (ret!=0)
{
perror("pthread:");
}
cout << "hello" << endl;
sleep(1);
return 0;
}
linux c--进程创建传值
猜你喜欢
转载自blog.csdn.net/z15005953031/article/details/113915206
今日推荐
周排行