Separate out pthread code.