Data integrity first
Multi-threaded code can be complex. With the advent of java.util.concurrent, multi-threaded code can now usually be written at a higher level than was previously possible. However, multi-threaded code can still be complex.
One should likely treat the basic thread-safety of a class as being fundamental. Performance optimizations and "tricky" code should likely be avoided unless they're necessary.
As usual, when faced with various implementation decisions, one should weigh carefully the pros and cons, such as:
- will the maintainer be comfortable maintaining the code? Would a simpler implementation suffice?
- is each performance optimization really worth it? Has its benefit been measured, and is it significant?
Would you use this technique?
|
|