Fix locks (I think).

I was getting into a condition (Java 7 on OS X) where the writeLock vs readLock were conflicting. The holder of the writeLock was semi-busy-looping, waiting for the `writeCache` to empty, but never released the lock (or awaited a condition) before entering that loop.
Merge pull request #49 from csm/master

Locking fixes (I think)