Fixed build for Linux and Macos. Probably usage of pthread is ambiguos. should be checked