Update threading code