Do simple booleans really need protecting (multithreading)
Riccardo Cohen
rcohen at articque.com
Tue Jan 15 04:47:31 PST 2008
you can avoid protecting the bool if only one thread writes in it and
the other reads it.
Brian Vanderburg II wrote:
> This is a question about multithreading. I'm using wxThread and have a
> data structure with some information, including two bools 'terminate',
> and 'finished' which are both initially false. The rest of the data
> does need protecting, but do these two variables 'really' need to be
> protected by anything? The thread frequently checks the 'terminate'
> variable, so even if it reads it at the same time another thread writes
> it and gets the wrong value (maybe false when the other thread is
> setting it to true), the next time it reads it it would read the it as
> true instead. Is there any real danger/problem with not protecting
> these two with a critical section/mutex?
>
> Brian Vanderburg II
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
>
--
Très cordialement,
Riccardo Cohen
-------------------------------------------
Articque
http://www.articque.com
149 av Général de Gaulle
37230 Fondettes - France
tel : 02-47-49-90-49
fax : 02-47-49-91-49
More information about the wx-users
mailing list