Scope of the Java System Properties

前端 未结 7 774
灰色年华
灰色年华 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:33

    There is one copy of the properties per VM. They have much the same problems as other statics (including singletons).

    I guess, as a hack, you call System.setProperties to a version of Properties that responds differently depending on the context (thread, call stack, time of day, etc.). It could also log any changes with System.setProperty. You could also set a SecurityManager logs security checks for the relevant permissions.

提交回复
热议问题