I am trying to understand pthreads by example. I have made the following code that is giving different answers everytime I run! Could anyone explain the bug please?
TIA,
Svi
I realize this post is old, but, alternatively, you may use a pthread_exit() at the end of main() so that main() will wait for all its peer threads to finish before exiting prematurely.