pthreads on OS X

Fix #869