Article View: borland.public.cppbuilder.nativeapi
Article #16170race conditions!!
From: Tharun Pillay
Date: Thu, 29 May 2003 12:39
Date: Thu, 29 May 2003 12:39
14 lines
1667 bytes
1667 bytes
My multi-threaded server app is simulating "race conditions" - one of the threads is firing before the other, when it mustn't. My worker thread is responsible for pooling, queues, etc. and my deallocation thread frees memory when the threads in the pool have terminated (it does this by checking GetExitCodeThread). I've managed to solve it by setting a flag for when the deallocation thread can free, though this seems a bit prone to disaster. Especially since the worker threads objects are derived from a base class and setting the flag is the classes responsibility. I've read up on semaphores but can't quite figure out how to implement them in code - maybe I'm being a bit stupid. Ideas? Tharun
Technical Details
Message-ID:
<3ed5feaf@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!38.144.126.70.MISMATCH!feed3.newsreader.com!newsreader.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,920bad3f7b14165b,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-05-29 05:59:54 PST From: "Tharun Pillay" <tharun@webmail.co.za> Newsgroups: borland.public.cppbuilder.nativeapi Subject: race conditions!! Date: Thu, 29 May 2003 14:39:14 +0200 Lines: 16 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 196.15.202.200 Message-ID: <3ed5feaf@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1054211759 196.15.202.200 (29 May 2003 05:35:59 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!38.144.126.70.MISMATCH!feed3.newsreader.com!newsreader.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail