linux 线程

#include <pthread.h>
vector<int> m_vectSelectDataHander;
typedef map<int, int> templatemap;
templatemap MapPthreadID;

void *thread1(void*)
{
	int nPthread = MapPthreadID[pthread_self()];
}

for(int i=0;i<n;i++)
m_vectSelectDataHander.push_back(0);
for(int i = 0; i < m_vectSelectDataHander.size(); i++)
{
	pthread_create((pthread_t*) & m_vectSelectDataHander[i], NULL, &thread1, NULL);
	int nPthreadID = m_vectSelectDataHander[i];
	MapPthreadID[nPthreadID]=i;
}
for(int i = 0; i < m_vectSelectDataHander.size(); i++)
pthread_join(m_vectSelectDataHander[i],NULL);


 

原文地址:https://www.cnblogs.com/byfei/p/14104725.html