I have a static class with a few methods that just take in a byte array, parses it, and returns a structure. I need to call these methods from many separate threads. Do I need a lock() or some kind of thread-safety within the methods? I can’t get my head around it.
Share
If your method is reentrant you don’t need any locks.
In general, you need locks whenever multiple threads access a shared resource. When the method just calculates something from its arguments without accessing any shared resource, there is nothing to lock.