P
Peter K
Hi
an application I am working on has a class with a static class variable
"LastIndex" which various (static) methods in the class can set.
The idea is that callers of this class can see the "last valid index" after
various method calls.
But this class is used in a multithreaded application, and I am sure that
this will cause confusion as it could be possible that multiple threads
could execute methods in the class, updating LastIndex - so none of the
multiple threads really know what "their" last index is. Is that a correct
appraisal?
Assuming my understanding is correct, how could I fix this? Is it possible
to have a "thread static variable" in the class? Then there is actually a
new copy of this class variable per thread which uses the class... so each
thread knows its own "last index".
Thanks,
Peter
an application I am working on has a class with a static class variable
"LastIndex" which various (static) methods in the class can set.
The idea is that callers of this class can see the "last valid index" after
various method calls.
But this class is used in a multithreaded application, and I am sure that
this will cause confusion as it could be possible that multiple threads
could execute methods in the class, updating LastIndex - so none of the
multiple threads really know what "their" last index is. Is that a correct
appraisal?
Assuming my understanding is correct, how could I fix this? Is it possible
to have a "thread static variable" in the class? Then there is actually a
new copy of this class variable per thread which uses the class... so each
thread knows its own "last index".
Thanks,
Peter