> You know...something seemed odd about it, but I was going to > go with it anyway...I'm still pretty sure that an increment > operation is not atomic, but I can't be sure. > > Regardless, the example statement given in the original post > was something like: > > x = y++; > > And I'm almost 100% certain that's not atomic, as the > increment of y and assignment to x are two separate operations.
The increment of y is not guaranteed to be atomic as it involves a read, an increment and then a write. These operations may be interleaved with operations on another thread. This is before you have the assigment to x. The iinc operator is only for local method variables and therefore not visible in other threads. If you change the code to the following then you should see different bytecode. public class Test { private int x ; // instance variable public int testInc() { x++; return x; } public int testAdd() { x = x + 1; return x; } } Kev Kevin Conner Orchard Information Systems Limited Newcastle Technopole, Kings Manor Newcastle Upon Tyne, NE1 6PA. United Kingdom Registered in England, Number 1900078 Tel: +44 (0) 191-2032536 Fax: +44 (0) 191 2302515 ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development