Correctly updating a static
field from a non-static method is tricky to get right and could easily lead to bugs if there are multiple class instances and/or multiple threads in play. Ideally, static
fields are only updated from synchronized static
methods.
This rule raises an issue each time a static
field is updated from a non-static method.
从非静态方法正确更新静态字段很难做到正确,如果有多个类实例和/或多个线程在起作用,则很容易导致错误。理想情况下,静态字段仅从同步静态方法更新。
每次从非静态方法更新静态字段时,此规则都会引发一个问题。