On 4/2/08, Charles Oliver Nutter <[EMAIL PROTECTED]> wrote:
>
>  John Wilson wrote:
>  > That is rather odd.
>  >
>  > Shouldn't count be volatile?
>  >
>  > If it's declared as volatile does that make any difference?
>
>
> I had not tried it because I expected volatile would only make it
>  slower. And in this case, the code in question didn't really care about
>  perfect accuracy for the counter since it's just a rough guide. But
>  here's numbers with volatile on my machine:

Interesting. I thought that the runtime system might have inferred
that count should have been volatile but you numbers show that this is
not the case.
[snip]

>  I tried another non-volatile run using i += 1 rather than i++ and the
>  numbers were almost identical, with Java 6 severely degrading with
>  multiple threads running and Java 5 improving.
>

It would be interesting to try:

tmp = i;
tmp++;
i = tmp;

for tmp as a local variable and again for tmp as a public instance field.

(I'm sorry I can't do the tests for mystelf as I don't have access to
a muti core machine here).

John Wilson

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to