pthread thread priority code refactoring