A.O.A
I have these two starting tutorials on POSIX threads programing,but when I compile it on either Redhat or Mandrake 10,this error is generated
undefined attribute in pthread_create().I think it shows the error due to soem arguemenst in this funcaion but I have downloaded this code from a tutorial so do't know what's wrong.Here is the code
#include<stdio.h>
#include<pthread.h>
void print(void * ptr);
int main(int argc,char*argv[])
{
pthread_t thread1;
sleep(1);
char *msg="Hye";
print(msg);
pthread_create(&thread1,NULL,print,(void *) msg);
printf("hello %s\n",argv[1]);
}
void print(void * ptr)
{
char *message;
message=(char*)ptr;
printf("%s",message);
pthread_exit(0);
}
/////// Code 2 ////////////
void print(void * ptr);
int main(int argc,char * argv[])
{
pthread_t thread1,thread2;
char *message1="Hello";
char *message2="World";
pthread_create(&thread1,pthread_attr_default,(void*)&print,(void*)message1);
sleep(10);
pthread_create(&thread2,pthread_attr_default,(void*)&print,(void*)message2);
sleep(10);
exit(0);
}
void print(void * ptr)
{
char *message;
message=(char*)ptr;
printf("%s",message);
pthread_exit(0);
}
Pls respond quickly,Thanks