Locks on the head and the tail

darin —  November 1, 2009 — Leave a comment

It’s been one of those kinds of weeks. I’ve been working on implementing a LinkedBlockingQueue for a project and things were not working as expected. Unfortunately, I forget the simplest of rules for LBQs: there is a lock on the head and a lock on the tail. I was processing the queue using a Timer in Spring and was calling queue.take(). However, when I would look at the log, I would only see a handful of entries saying the take was happening then it would appear to stop.

That was my fatal mistake.

If I would have read the not-so-fine print on for the API on take(), I would have seen:

“Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.”

It wasn’t that processing was stopping, it was that it was waiting for something to hit the queue.

My next step is to hook the queue up into Terracotta and make it cluster-aware so I have failover in case one of the nodes goes down. Should be smooth sailing from here. At least I hope so 🙂

I’m starting the design and coding for an Android version of a best-selling iPhone financial app this week. I’m really looking forward to going heads down and knocking this out.

I’m also looking forward to the release of the Droid phone this week. However, I’ll let someone else be the first on the block to get one. I’m still in love with my iPhone, but hopefully AT&T’s coverage will be starting to rival Verizon’s or I’ll be defecting once my contract is up.

I’m also considering switching from my current home phone and internet provider to Clear. They are launching in Charlotte this week and their pricing is *much* more attractive than Time Warner. However, I’m hoping to get an eval unit for a couple of hours to check out coverage at the house. Hopefully I can give you more info on this over coming weeks. I’ve been happy with Time Warner, but they have been the only game in town where I live, so I’m hoping Clear will give us a good 2nd option.

Finally, my update on Windows 7. Even though I’m a Mac fanboy, I have to say that I am freakin’ impressed by Windows 7. I did a clean install of Windows 7 Pro 64 bit last weekend on a low end Dell Studio (can’t run XP compat mode) and from time of insert of DVD to running Win7 was under 20 minutes. I can’t get any Linux or Mac installs to go that fast. I was highly impressed. Then, I used Ninite Easy PC Setup and Multiple App Installer to install the normal stack of Windows apps that I use (Chrome, Firefox, Skype, etc). Man, what an amazing little app. It only took a few minutes and 80% of the apps I use were installed in almost one click.

My overall impression with Win7 is pleasantly surprised. I’m still sticking with Mac OS X for now, but I really like what I see with Win7 and at this point I wouldn’t think twice about switching over if I needed to.

If you have any iPhone, Android or Terracotta questions you need answered, leave a comment below.

Darin Pope

darin

Posts