Static variables and multithreading in java

后端 未结 7 1729
心在旅途
心在旅途 2020-12-02 13:31

Is a static member of a class present as only a single instance per process or thread? Meaning does each thread has its own copy of the static member variable of the class?

7条回答
  •  被撕碎了的回忆
    2020-12-02 14:03

    Actually class variable corresponds to the class, in it shares only single memory, so changes made by each instance of class can change the class variable.

提交回复
热议问题