Use compare-and-set!. Duh.