fixed thread set function