You are not linking pthread properly, try below command(note: order matters)
g++ main.cpp -o main.out -pthread -std=c++11
OR
Do it with two commands
g++ -c main.cpp -pthread -std=c++11 // generate target object file
g++ main.o -o main.out -pthread -std=c++11 // link to target binary