Quote:
Does the execution of threads differ at every execution?
Yes, it always differ because Os already have hundred of threads running continuously and it is impossible to repeat exact same conditions on 2 runs.
Quote:
this function's result is also different. Is this they way it is supposed to be?
If result reflect thread scheduling, it is normal.
If result is computation, it is not normal. You have to design your code to take into account this behavior of threads.