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
PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [JBoss-dev] is x++ an atomic operation??
Date: Thu, 18 Jul 2002 08:54:43 -0400
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
] is x++ an atomic operation??
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
if
this operation is atomic or not, but this invalidates the logic of the jguru
post.
-Larry
- Original Message -
From: Rhett Aultman [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, July 18, 2002 6:24 AM
Subject: RE: [JBoss-dev] is x++ an atomic operation??
I'm fairly sure
not atomic, as the increment of y and assignment to
x are two separate operations.
-Original Message-
From: Larry Sandereson [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 18, 2002 9:32 AM
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-dev] is x++ an atomic operation??
The jguru article
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%
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)
not atomic. Thanks.
-Larry
- Original Message -
From: Kevin Conner [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, July 18, 2002 7:19 AM
Subject: RE: [JBoss-dev] is x++ an atomic operation??
You know...something seemed odd about it, but I was going to
go with it anyway...I'm
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