I have a lot of multithreading bugs since I introduced a second worker thread. The issues are minor and hard to trace. My latest indications point to
class MyOtherClass {
static String defaultName;
static String getDefaultName() {return defaultName;}
}
which is being used by:
result plainLocalFunction() {
result r = E_SUCCESS;
String fallbackName = MyOtherClass::getDefaultName();
//Do other stuff with locals.
return r;
}
I’ve been ages debugging this and I can only suppose that either the plainLocalFunction is shares its locals between threads or that that the call to getDefaultName() involves writing to a static variable which is not thread safe? Thanks for your time.
static variables inside a function would render your function not re-entrant and not thread safe.
If you have just local variables in a function then each thread stack will have its own copy of those variables and the function will be thread safe.