Being a lazy programmer, I've always found that if I'm spending my few 
remaining neurons trying to figure out what operation is truly atomic 
and what isn't, I'll be better off designing the system in such a way 
that it doesn't matter.

I've spent enough time grovelling through disassembled compiler output 
trying to figure out how Visual C++ had screwed me this time to never 
want to go through the experience again.

Put another way - the fact that you need to know if an operation is 
atomic means that you have a critical section. Since you have a critical 
section, synchronize it and keep it short.

-danch

Dain Sundstrom wrote:
> 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
> 
> 
> 





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