On 2008.04.02., at 10:48, Charles Oliver Nutter wrote: > > So I'm rather confused here. Is a ++ operation on a static int doing > some kind of atomic update that causes multiple threads to contend?
No. You know your JVM bytecodes, Charlie - the only incrementing bytecode in existence is IINC and it only works on an integer local variable. 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. Attila. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---