🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #7574

Re: Accessing same variable from multiple threads

#7574
From: Remy Lebeau (TeamB)
Date: Thu, 20 Jan 2005 17:45
30 lines
2424 bytes
"Vladimir Afanasyev" <avv@systema.kiev.ua> wrote in message
news:41efa03e$1@newsgroups.borland.com...

> Frankly my first answer was critical section and semaphor.
> But I think that in easiest case no need to use synchronization.

Yes, you do need to use synchronization.

> Really because one variable can be changed to some variables or
> structure via refactoring the using semephors and critical sections
> preferable. If think that better way will be if reading thread creates
> another thread that will have sole task - listen/watch for
> variables.

That just complicates the design even more, and doesn't even solve the
problem at all.  You still have to synchronize, and now you've introduced
another thread that still has to synchronize as well

> This thread (in my opinion) must use semaphor for watching for
variable(s).

You just contradicted yourself.  First you said that synchronization is not
needed, but then you offer an approach that uses synchronization.  But it
still won't work.  A critical section or semaphor wil not work unless ALL
threads accessing the shared data use them.  Otherwise they do not provide
any protection at all.


Gambit
Technical Details
Message-ID: <41efed8e$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!proxad.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41edea6b@newsgroups.borland.com> <41ee3727$1@newsgroups.borland.com> <41ee742e$1@newsgroups.borland.com> <41ee8f57$1@newsgroups.borland.com> <41ee9bd1$1@newsgroups.borland.com> <41eea799$1@newsgroups.borland.com> <41eed116$1@newsgroups.borland.com> <41efa03e$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,4809cdd9a7828fa7
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References:  <41edea6b@newsgroups.borland.com> <41ee3727$1@newsgroups.borland.com> <41ee742e$1@newsgroups.borland.com> <41ee8f57$1@newsgroups.borland.com> <41ee9bd1$1@newsgroups.borland.com> <41eea799$1@newsgroups.borland.com> <41eed116$1@newsgroups.borland.com> <41efa03e$1@newsgroups.borland.com>
Subject: Re: Accessing same variable from multiple threads
Date: Thu, 20 Jan 2005 09:45:02 -0800
Lines: 32
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <41efed8e$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1106242958 68.69.17.41 (20 Jan 2005 09:42:38 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!proxad.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail