The correct way to retrieve the passed parameter follows
void *smoker_tobacco (void *id)
{
long tid = (long)id;
cout << "Thread id:"<< tid << endl;
return (void *) 0;
}
Try, for instance
#include <iostream>
#include <pthread.h>
#include <semaphore.h>
using namespace std;
void *smoker_tobacco (void *id)
{
long tid = (long)id;
cout << "Thread id:"<< tid << endl;
return (void *) 0;
}
int main()
{
pthread_t smoker1,smoker4;
sem_t table, sem_tobacco, sem_paper, sem_match;
sem_init(&table,0,1);
sem_init(&sem_tobacco,0,0);
sem_init(&sem_paper,0,0);
sem_init(&sem_match,0,0);
pthread_create(&smoker1, NULL, smoker_tobacco, (void*)1);
pthread_create(&smoker4, NULL, smoker_tobacco, (void*)4);
cout<<smoker1<<","<<smoker4<<endl;
pthread_join(smoker1,NULL);
pthread_join(smoker4,NULL);
return 0;
}