|
Originally posted by Henry Wong:
Now, as to which is faster, it would depend on how they are used. But in the general case, the second should be faster.
Originally posted by Ernest Friedman-Hill:
Interesting! Not contradicting you at all, Henry, I'm just not as familiar with java.util.concurrent as I should be. Can you cite evidence for this claim? I didn't think any of the java.util.concurrent stuff used native magic; if so, it's going to be using synchronization under the hood, so I would guess the performance would be a wash (if it's not slower due to the one extra indirection, that is.) You're the expert here, though, so I'm looking forward to your reply.
SCJP 5, SCDJWS<br /> <br />It's amazing how premature optimisation is both seductive and destructive; even when you know
Originally posted by Swapnil Shroff:
Is it still thread safe?
SCJP 5, SCDJWS<br /> <br />It's amazing how premature optimisation is both seductive and destructive; even when you know
SCJP 5, SCDJWS<br /> <br />It's amazing how premature optimisation is both seductive and destructive; even when you know
Originally posted by Swapnil Shroff:
I think it is not atomic as it can be divided in to more simpler code like
Am I right Henry?
Originally posted by Henry Wong:
...In this case, it is possible for the string to change, between the time the string is loaded, appended, and then stored back into memory. This means that it is possible for two threads, to call the append method, and for one of the appended strings to be lost.
Henry
Originally posted by Mr. C Lamont Gilbert:
Just to clarify, I said effectively atomic.
No moreso than with
Which you did call atomic right? The point I am making is they share the same level of atomicity.
Since both method calls are atomic operations, I would say that the "least costly" method is to just change the variable to volatile
M Easter
Software Composer - http://codetojoy.blogspot.com
You've gotta fight it! Don't give in! Read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|