You are on page 1of 1

#include <pthread.

h>
#include <iostream>
using namespace std;
int count=0;
void *print_message(void *ptr)
{
count++;
pthread_t id;
cout<<"Hello i am thread"<<count<<endl;
id=pthread_self();
cout<<endl<<"my id is "<<id;
pthread_exit(NULL);
}
int main()
{
pthread_t threads[10];
for(int i = 0; i < 10; i++)
{
pthread_create(&threads[i],NULL ,print_message ,NULL);
}
for(int i = 0; i < 10; i++)
{
pthread_join(threads[i], NULL);
}
return 0;
exit(0);
}

You might also like