Piotr Gabryanczyk’s Blog

Java, Refactoring, AOP, Spring, DDD, TDD, etc.

  • Blogroll

    • I have joined Anti-IF Campaign

Archive for May, 2007

Wait-free, lock-free in Java 5 concurrent

Posted by Piotr Gabryanczyk on May 6, 2007

I recently came across few interesting articles by Brian Goetz:

I recommend it to anyone interested in parallel programming in Java!

Posted in concurrent, java | Leave a Comment »

Synchronized – not dead yet

Posted by Piotr Gabryanczyk on May 6, 2007

Some time ago the guy I worked with started replacing all synchronized blocks with new reentrant locks (Java 5). He went to some presentation and was told that they are superior.

It looked like a weird thing to do, especially if reentrant locks had the same semantics as synchronized block.

No rush

Here is how Brian Goetz arguments no rush to replace synchronized with new locks:

“While ReentrantLock is a very impressive implementation and has some significant advantages over synchronization, I believe the rush to consider synchronization a deprecated feature to be a serious mistake. The locking classes in java.util.concurrent.lock are advanced tools for advanced users and situations. In general, you should probably stick with synchronization unless you have a specific need for one of the advanced features of Lock, or if you have demonstrated evidence (not just a mere suspicion) that synchronization in this particular situation is a scalability bottleneck.”

Advanced tools for advanced users

I also like this comment:
“Remember, these are advanced tools for advanced users. (And truly advanced users tend to prefer the simplest tools they can find until they’re convinced the simple tools are inadequate.)”

Full article here: More flexible, scalable locking in JDK 5.0

Posted in concurrent, java | Leave a Comment »