Add -pthread.

-pthread introduces -lpthread and -D_REENTRANT.
-D_REENTRANT is required for safety.