Lock threads so that this at least sort of works