Mmmm, I can write you a criteriaFind implementation that does not need to be synchronized (although it admittedly wouldn't be the most straightforward). Really, it is an implementation detail, and ideally a certified Java developer would be able to look at an implementation and determine if it needs synchronization or not.
Originally posted by Gennady Shapiro:
findXXX should be synchronized. No doubt.
There has been quite a bit of discussion about threads and synchronization so far. If you aren't able to decide at this point whether the criteriaFind() method needs to be synchronized or not, there are apparently still some gaps in your knowledge of the topic. Rather than hand you the answer on a golden plate, I'd strongly suggest you read up some more on threads.
Originally posted by Devu Shah:
My Q. still remain unanswered....
Overly clever people like Sun? For instance, both Vector.size() and Vector.isEmpty() access the elementCount private variable but neither is synchronized in any way. Joshua's recommendation is a safe one, though; anything else is a performance optimisation that should be made only when strictly necessary, by an expert. Calling this "wrong" so categorically is, however, mistaken.
Originally posted by mitchner green:
[Joshua Bloch] states you should *always* synchronize access to shared, mutable data. [...] he goes on to explain that overly clever people try to increase concurrency by not synchronizing atomic operations. This is dangerous and wrong.