Scope of the Java System Properties

前端 未结 7 782
灰色年华
灰色年华 2020-11-30 02:55

In Java we use System.setProperty() method to set some system properties. According to this article the use of system properties is bit tricky.

System

7条回答
  •  孤城傲影
    2020-11-30 03:41

    System properties are per-process. This means that they are more global than static fields, which are per-classloader. So for instance, if you have a single instance of Tomcat running multiple Java webapps, each of which has a class com.example.Example with a static field named globalField, then the webapps will share system properties, but com.example.Example.globalField can be set to a different value in each webapp.

提交回复
热议问题