C# variable thread safety
- Yes you should synchronize access to it, if it is a primitive type there are methods to do this for you without locks
- no comment
- not sure by what you mean by this... most likely you'll end up inserting the wrong value into the DB
- Don't use
volatile
, per Eric Lippert, it's overly complicated and the semantics are very weird.
Be careful of breaking the memory model, C# by and large follows most other languages in using sequential consistency for data-race-free programs (SC-DRF). Volatile breaks this, so just use locks to prevent a data race.
As for lock
it's not as heavy as one might imagine, in most cases the lock won't be contended in the scenario you imagine. So acquiring the lock should be painless in most cases.