WINDOWS - added more error checking to threading