Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Two more multithreading questions

Reply
Thread Tools

Two more multithreading questions

 
 
Knute Johnson
Guest
Posts: n/a
 
      02-01-2007
A. Bolmarcich wrote:
> On 2007-02-01, Knute Johnson <(E-Mail Removed)> wrote:
>> A. Bolmarcich wrote:
>>> Like many questions about the interaction of multiple threads, the
>>> question does not have a simple "yes" or "no" answer. The best that I
>>> can respond is to repeat: a read is subsequent to a write that wrote the
>>> value that was read. If that is what you mean by "subsequent read" in
>>> your qestion, the answer is "yes".

>> I have no idea what that means. By subsequent I mean the usual meaning
>> that the subsequent action occurs later in time than the precedent
>> action. So in the case I am asking about, the first thread writes to
>> the variable and then some time later the second thread reads the variable.
>>
>> Does volatile guarantee that the second thread will see the value
>> written by the first thread?
>>
>> Does synchronizing guarantee that the second thread will see the value
>> written by the first thread?

>
> When "the first thread writes to the variable" a processor requests that
> a value be written to a memory address. On some computers the request
> goes into a queue and the effect of the memory write is visible to other
> threads sometime later. While the memory write is being done, the first
> thread continues executing.
>
> On this type of computer architecture, whether a memory read is subsequent
> to a memory write depends on the whether the read gets the value written
> by the memory write. It does not depend on the global order in which
> threads execute instructions.
>
> The answer to your question: "Does volatile guarantee that the second
> thread will see the value written by the first thread?", is yes, as long
> as you take "some time later" being in terms of what is visible in memory
> and not in terms of the global order in which the threads execute the
> instruction.
>
> The answer to your question: "Does synchronizing guarantee that the
> second thread will see the value written by the first thread?" is yes,
> with "some time later" being in terms of the second thread entering its
> synchronized block after the first thread exited its synchronized block.


Thanks very much. I appreciate the time and effort.

--

Knute Johnson
email s/nospam/knute/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Two more questions Frank Winkler Cisco 0 02-19-2008 10:26 AM
How to compare two SOAP Envelope or two Document or two XML files GenxLogic Java 3 12-06-2006 08:41 PM
Kamaelia 0.4.0 RELEASED - Faster! More Tools! More Examples! More Docs! ;-) Michael Python 4 06-26-2006 08:00 AM
Two more questions chlori HTML 6 01-21-2005 12:04 PM
substitute two ore more with two or more Robert Wallace Perl Misc 1 12-31-2003 05:13 PM



Advertisments