The following program does not terminate. The execution gets suspended in the thread at the cout. Is it due to buffering used in cout;Cause the same code is working fine with the Red hat version 6.2. Waiting for an early reply. #include<pthread.h> #include<unistd.h> #include<iostream.h> #include<string.h> class Thread3{ private: char Mesg[]; static void* Fn(void* Param) { char *Ptr = (char*)Param; cout<<Ptr<<"\n";//EXECUTION SUSPENDED AT THIS POINT return 0; } public: Thread3(){ strcpy(Mesg,"Hello World"); pthread_t tid; pthread_create(&tid,NULL,&Fn,(void*)Mesg); cout << "Thread Created" << endl; pthread_join(tid,NULL); cout << "Thread Joined" << endl; } }; main(){ Thread3 t; }
Please install libstdc++-2.96-69 or above (this was released as gcc errata in December).