Rather randomly and on a legacy note – here’s a series of links on the subject of java concurrency bug patterns from both IBM DeveloperWorks and from Alex Miller at Pure Danger Tech both for my reference and yours. Most readers, I expect will know all of this, but if you don’t the list is worth reading. It’s also good to raise awareness of such concurrency bug patterns in general as a surprisingly large number of interview candidates fail to answer questions correctly in this area.
- Java concurrency bug patterns for multicore systems
- Java Concurrency Bugs #1 – mutable statics
- Java Concurrency Bugs #2 – what to synchronize on
- Java Concurrency Bugs #3 – atomic + atomic != atomic
- Java Concurrency Bugs #4: ConcurrentModificationException
- Java Concurrency Bugs #5: inconsistent synchronization
- JavaOne: Java Concurrency Gotchas
In general, although most people tend to consider this optional or are blissfully unaware of it, documenting the thread safety of your code is very good practice and essential if you consider that FindBugs detects them and validates your assertions.