Fix building threads with mingw-w64