Hi. This is Kobungyo. Following Program is deadlocked under RedHat 7.0 when dynamic linked. But it work correctly under RedHat6.2 in both dynamic link and static link. Can I use fstream class from 2 or more threads simultaneously ? $ c++ a.cc -lpthread <- does not work $ c++ -static a.cc -lpthread <- ok. but the object is too large. -- #include <iostream> #include <fstream> #include <pthread.h> using namespace std; ofstream file; void *func(void *){ file << "Hello, again!" << endl; pthread_exit(NULL); } int main(){ file.open("a.txt"); file << "Hello, Wordl!" << endl; pthread_t t1; pthread_create(&t1, NULL, func, NULL); pthread_join(t1, NULL); }
*** This bug has been marked as a duplicate of 18339 ***