Add -pthread to compilation flags for linux

Because some versions of gcc may not automatically add it.