DCO_81
Member level 1
- Joined
- Mar 10, 2005
- Messages
- 39
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,288
- Location
- Germany, south
- Activity points
- 1,657
Hi,
I have this simple concurrent prog with 2 threads. It compiles fine but when I start it I get a segmentation fault. Why?
I have this simple concurrent prog with 2 threads. It compiles fine but when I start it I get a segmentation fault. Why?
Code:
#include <pthread.h>
#include <iostream>
using namespace std;
void fun1()
{
for (int i=0; i < 100; i++)
cout << "1" << endl;
pthread_exit(0);
}
void fun2()
{
for (int i=0; i < 100; i++)
cout << "2" << endl;
pthread_exit(0);
}
void concurrent(void (a()), void (b()))
{
pthread_t pt1, pt2;
pthread_create( &pt1,
NULL,
(void* (*) (void*)) a,
NULL);
pthread_create( &pt2,
NULL,
(void* (*) (void*)) b,
NULL);
}
void main()
{
concurrent(fun1, fun2);
}