You probably do not need locks in this case. However, you should retrieve a copy of the variable and use that copy exclusively in the main thread. If you didn't and you accessed the variable multiple times (within one Update() call), you might be reading different values, which can be problematic.
The only issue you might have is with that variable holding an object reference. If an object reference is used, you might have issues with the worker thread modifying the object after you have retrieved its reference. If the worker thread does not touch the object after assigning it to the variable, then you should be ok.
Multi-threading is a headache causing concept in programming, and is often considered an advanced concept because of this situation. I would advise reading up as much as you can about the topic. Unless you really need it, I would avoid using multithreading (use co-routines if you can).
↧