🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Accessing same variable from multiple threads

#7540
From: Peter Str�mberg
Date: Wed, 19 Jan 2005 11:55
15 lines
1472 bytes
"Tumurbaatar S." <nospam_tumur@magicnet.mn> wrote in 
news:41edea6b@newsgroups.borland.com:

> There's a integer variable visible to 2 threads. One of the threads
> reads/modifies this var, but other thread only reads it.
> But an exact value of the var is not important for the 2nd thread.
> The thread checks it for zero or not, i.e. "if (my_var)...".
> Is it not matter that I'm not using any synchronization methods? 

If you don't want to use synchronization methods then declare the variable 
volatile

-- 
Peter Str�mberg (55.6N 13.0E)
C2K2 C2K3 ISCCIV02 ISCCIV03 ISCCIV04
Technical Details
Message-ID: <Xns95E38368CDE60wilfriedspamcopnet@207.105.83.66>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!zen.net.uk!dedekind.zen.co.uk!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>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,4809cdd9a7828fa7
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Accessing same variable from multiple threads
From: "Peter Str�mberg" <wilfried@spamcop.net>
References: <41edea6b@newsgroups.borland.com>
Message-ID: <Xns95E38368CDE60wilfriedspamcopnet@207.105.83.66>
User-Agent: Xnews/06.12.01
NNTP-Posting-Host: 194.71.160.182
Date: 19 Jan 2005 03:55:04 -0800
X-Trace: newsgroups.borland.com 1106135704 194.71.160.182 (19 Jan 2005 03:55:04 -0800)
Lines: 15
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!zen.net.uk!dedekind.zen.co.uk!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