Fix threads in setTimeout implementation