From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8914 invoked by alias); 21 Aug 2002 21:59:40 -0000 Mailing-List: contact pthreads-win32-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sources.redhat.com Received: (qmail 8907 invoked from network); 21 Aug 2002 21:59:39 -0000 Received: from unknown (HELO nycsmtp2out.rdc-nyc.rr.com) (24.29.99.227) by sources.redhat.com with SMTP; 21 Aug 2002 21:59:39 -0000 Received: from victory (66-65-44-29.nyc.rr.com [66.65.44.29]) by nycsmtp2out.rdc-nyc.rr.com (8.12.1/Road Runner SMTP Server 1.0) with SMTP id g7LLvVOx016220; Wed, 21 Aug 2002 17:57:31 -0400 (EDT) Message-ID: <000f01c2495e$0b2bab80$1d2c4142@victory> From: "Wayne Robin Isaacs" To: "Kyle Boon" , References: <20020821190248.28CFB3BDBF@toledo.bmi.ohio-state.edu> Subject: Re: Simple question. Date: Wed, 21 Aug 2002 14:59:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 X-SW-Source: 2002/txt/msg00091.txt.bz2 Hi, Kyle. As long as you use multi-threaded libraries in your project->settings, "cout" will be thread-safe in VC++. I'm not sure how you're calling "cout", but there may be a discrepancy in usage between iostream/Linux and iostream/Windows. If you use statements like: void threadfn(void*) { for(int i=100;i--;) cout << "o" << "o" << endl; } main() { _beginthread(threadfn,0,0); for(int i=100;i--;) cout << "x" << "x" << endl; getchar(); } .. then your output should be all mixed up, because each line compiles to three separate calls to "cout". The gcc compiler may combine these calls as an optimization, but you shouldn't code assuming that, because it's an implementation artifact. Rather than implementing a serialization thread, it might be simpler to send your strings to a stringbuffer first, then output that buffer in a single "cout" call. Wayne Isaacs ----- Original Message ----- From: "Kyle Boon" To: Sent: Wednesday, August 21, 2002 3:02 PM Subject: Simple question. > I'm not sure if this is the right place for my question - so I apolgize in > advance if it not. > > First some quick background. I am a college undergrad charged with porting a > linux app to the win32 platform. I chose this pthreads implementation to make > the task much easier. So far it's worked very well. My only question is how > people deal with console output. I have multiple threads using cout to print > things to the console, but the output is all jumbled up. If I try to link > with a thread safe version of the standard library on windows, I get all > sorts of linker errors. It seems like people must have had to work around > this before, but I haven't been able to find any information about it. > > Any help would be greatly appreciated. > Kyle Boon >