Hiram,

I this code is at least 2 operations.  Most of the atomic operations 
(except int assignment) are completely useless because you can't both 
invoke the operator and get the result in a single operation.  For example:

a: increment i (i=1)
b: increment i (i=2)
a: assign i to out (out = 2)
b: assign i to out (out = 2)

This discussion and the tx discussion are both "running  in the dark;" 
you don't know where you are and you don't know where you are going... 
work for work sake.

If you synchronized the code, what is the actual performance impact?  I 
can tell you that with Hot Spot the code is very little.  The real cost 
happens when you have lots of contention.  Do you have lots of 
contention for this code?

I always say synchronize it and if it is a real performance problem we 
will fix it during tuning.

-dain

Hiram Chirino wrote:
> Quick question for you Java Language Gurus out there, I heard one that the
> post increment operator was an atomic operation.  For example, if you have a
> multi-threaded application with:
> 
>       id=lastRequestId++;
> 
> You would not need to put this in a synchronized block be cause the ++ would
> be atomic and thus you would not get 2 duplicate ids.  I was wondering if
> this is true or not.  Can anybody confirm this for me??
> 
> 
> Regards,
> Hiram
> 
> 
> 
> -------------------------------------------------------
> 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


-- 
xxxxxxxxxxxxxxxxxxxxxxxx
Dain Sundstrom
Chief Architect JBossCMP
JBoss Group, LLC
xxxxxxxxxxxxxxxxxxxxxxxx



-------------------------------------------------------
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

Reply via email to