I just started using threads and I am having a problem were an INT global variable that is modified by a CREATED detached thread does not has the value I expect it to have after the CREATED thread finishes, how do I know the CREATED thread finished? I change to TRUE a global variable at the end of the function the CREATED thread is running. So in the MAIN thread (not exactly in the MAIN function code but inside a function, inside another function called by the MAIN) I check if this bool is true, if it is then I read the INT value but it isn't what I want it to be.
What I want to know is where can I find good tutorials about what not to do when using global variables in threads.