Subj : Re: acquiring a new value/ without any mutexes To : comp.programming.threads From : David Schwartz Date : Wed Jan 05 2005 01:35 am "John Torjo" wrote in message news:c638aac5.0406301104.4c79808d@posting.google.com... > Hi to all you thread gurus, > > Small question: > Say on a multi-processor machine I do something like this: > > // global variable > int i = 0; > > // at some point in time, > // when there are a lot of threads started > // from one thread > // > // (NO mutexes/thread locks at all) > i = 10; > > > Am I guaranteed that at some point in time ALL threads will get the > new value of i,as being 10 (as opposed to manually having to do a lock > in order for a thread to get the latest value of i - as being 10)? No, you are not. Specifically, code like: while(i==0) foo(); Will likely *never* see the new value. > I would assume so. So, I will go for the second question: > > What's the longest time it could take for a thread until it will > acquire this value (10)? Would it be safe to assume that is the order > of 1 millisecond, at most? It can be arbitrarily long. DS .