Add mutex to sync read-write cycle.