I did search the forums and the web.
And i did correctly add the -pthread in my make file
It appears the problem however, occured when i wrote my own makefile. I did this because i wasn't sure how to do add the -pthread flag with the cb menus.
I didn't update the output filename however, so code::blocks still launched my old executable without the -pthread from the debug folder, although it linked and placed the new one with -pthread in the project root.
Not C::B builds, links and places the executable if you use a custom makefile !
C::B does not know anything about the content of the makefile.
You can fix the place where C::B looks for the executables in "Project -> Properties -> Build targets -> Output filename".
If it points to the correct place, C::B can launch it.
You did not tell anything about a custom makefile in your original post, neither did you tell anything about the solutions you tried.
If you would have told us, that you want to add -pthread, but don't know where to do it, it would be easy to help you.
There are two places where it is probably needed: "Project -> Build options -> Compiler Settings -> Other options" and "Project -> Build options -> Linker settings -> Other linker settings", the last one is needed in any case, the first one seems to be unneeded for your testcase, but is most likely needed for more complex programs.
This still doesn't explain why the program exits with status 0 when i uncheck the pause checkbox
In both cases (without -pthread), the "Build log" shows the return code of 0, because it's the return code of the terminal that was called to run the executable in, it does not care about the programs return code (not a C::B issue, and absolutely correct if the terminal-emulator exits normally).
If you have checked "Pause when ...", the executable is run inside the terminal through a wrapper-program, that keeps the terminal open, so you can see the output, and that prints the return-code of your exe.
The "Build log" still says it's 0, becaue it still shows the return code of the terminal.
So everything is okay here.
Sorry for the inconvenience, i will probably never post here again.
That's your decision.