That's complicated. Yes, they are shared between threads - a static variable has one single instance for the whole life of the application - but that doesn't mean you can blindly change it's value in different thread simultaneously.
Think about it: in cmahine code terms,
x++
is not a single operation - it's a form of "syntactic sugar" which expands several to lines of code:
int y = x;
x = x + 1;
return y;
And if you have multiple threads executing that code at the same time, then some of them are going to get the wrong value, or return the wrong value because you have no control over which of those three lines any thread is executing at the same time.
The technical terms for this is that the operation is
not thread safe
.
So while static variables are "shared between threads" you have to be very careful what you do with them, or things get very unpredictable, very quickly.
Be aware that multithreading is not a simple magic bullet to fix performance problems: it needs to be thought about and planned massively in advance or it will give you more problems than it solves!
Have a look here:
Managed Threading Best Practices | Microsoft Docs[
^]