Detect pthreads

Pretty sure this fixes #160.