It looks properly synchronized to me, though I'm not sure if this is the approach I would take. I'll have to dig through the Java API and think about it before I can suggest a better alternative.