Nate touched on some of the features the newer versions of Java provide for concurrency at an OCI Java Lunch a couple of months earlier. Eric’s follow on Java Lunch concurrency topic nurtured the planted seed, but the BIG THANKS goes to Charles (I like calling him Charlie, with NO idea what he thinks) for sending out an email that provided the tipping point. I’m repeating facts (one of my patterns)… on to the show…
The screen shimmers and waves to a clear picture of six people sitting around a conference table. Some with books, others with laptops. Charles provides introductions and greetings, one attendee is even on the other side of a speaker phone working from home. The lunch time study group is REALLY on it’s way.
Chapter two of JCIP “Thread Safety” propones that the issue is about “managing access to state… shared mutable state”. If our programs don’t manage this correctly they are broke. That’s a capital period. The idea that’s trying to be communicated is that, what we used to believe about visibility of variables and objects, the order of execution of code, even the values that a variable has no longer is as simple as it was. Specifically when programs threads start running concurrently.
For me the moment of ‘Oh no, now what am I going to do’ came when it was pointed out the increment operation (i++) is not atomic, that it is a read, modify and write. The chapter went on to provide several insights into ways I need to think differently if I’m writing code for multiple thread access. Covering the topics of Atomicity, Locks, Guards, Liveness and Performance I was able to quickly grasp the authors’ definitions.
The book clearly shows me code that is broke and steers me to solutions on what I can do to make it correct. I am MOST grateful for the bits of humor, there is just not enough levity in this world. I enjoyed the discussion around the table and the time went by quickly. I was in a bit of a hurry, my tee time was quickly approaching. Slow fade…
Posted by dennisradio
Posted by Eric Burke