Another thing to note, which might be root cause of the bug, is that join_func() appears to be called multiple times according to the program output:
Joining thread 0 thread 0 joined! Joining thread 1 thread 0 joined! Joining thread 1
There is no way the program would want to join a thread multiple times.
Another thing to note, which might be root cause of the bug, is that join_func() appears to be called multiple times according to the program output:
Joining thread 0
thread 0 joined!
Joining thread 1
thread 0 joined!
Joining thread 1
There is no way the program would want to join a thread multiple times.