Merge pull request #1458 from rubenk/pthread-detection