Fix thread bug for clang