This thread seems to be describing this approach as not thread unsafe.
The author posted the solution but I don’t think I understand what he meant.