Attila Szegedi wrote:
> No. You know your JVM bytecodes, Charlie - the only incrementing  
> bytecode in existence is IINC and it only works on an integer local  
> variable.

Yes, I know that...but I hadn't dug into what code was actually being 
generated for a field++. Looking now they don't appear to be any 
different. Either way it doesn't give me any answers...

> Pretty much the only sane implementation of ++ on a static field would  
> be:
> 
> GETSTATIC someClass.someField
> ICONST_1
> IADD
> PUTSTATIC someClass.someField
> 
> Not even volatility of the field will ensure atomic increment  
> operations, as the value must be temporarily held on the thread  
> operand stack.
> 
> If you want atomic updates, java.util.concurrent.atomic.AtomicInteger  
> might give you what you need on Java 5 and above.

I'm more interested in finding out why the performance is so bad with 
multiple threads under Java 6. I don't need atomic updates, for which I 
would certainly use AtomicInteger instead.

- Charlie

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to jvm-languages@googlegroups.com
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