Given the following in C code:
// some .c source file
static int global_env = 0;
static void change_global_env() {
global_env = 1;
}
static void thread_task() {
if (gloval_env == 1) printf("good");
else printf("bad");
}
int main() {
change_global_env();
for(int i < 10) spawn_threads_with_thread_task();
}
Will everything print "good"?
In other words, does all the threads see the updated static global varible?
Because I do something similar and visual studio debugger gives me garbage numbers for the static var in the threads task but im not sure if this is just a fault in the debugger o…