Thread Safety

Although I have no idea what the possible implications of this change are, it was the only way I could get pthreads to build. I've only installed PHP 5.4 on OS X 10.8.2, please excuse me if there are issues elsewhere.