System.setProperty 的范围
如果我设置一个属性(例如 System.setProperty("http.keepAlive", "false")),它是否会影响系统中的所有应用程序、当前应用程序、当前任务或当前线程仅有的?
这是在哪里记录的?
What's the scope of System.setProperty in Android?
If I set a property (say System.setProperty("http.keepAlive", "false")
), does it affect all apps in the system, the current app, the current task or the current thread only?
Where is this documented?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Java“系统”属性不跨越进程边界,它们保存在内存中并绑定到虚拟机的单个实例。因此,如果您在应用程序中设置系统属性,设备上运行的其他应用程序将看不到该属性。
Java "system" properties do not cross process boundaries, they are held in memory and are tied to a single instance of the virtual machine. Therefore if you set a system property within application it will not be visible to other applications running on the device.
如果您没有在 Manifest.xml 中另外指定,同一应用程序的 Android 活动将在应用程序启动时在为该应用程序创建的默认进程中运行。
每个进程都在自己的 JVM 中运行。因此,基于 @mmccomb 的答案, System.setProperty() 将到达同一应用程序中的所有活动,除非您有意声明活动在不同的进程中运行。
请参阅http://developer.android.com/guide/components/processes- and-threads.html
Android Activities of the same application, if you don't specify otherwise in the Manifest.xml, will run in a default Process created for the application when it starts.
Each process runs in its own JVM. So the System.setProperty(), based on @mmccomb 's answer, will reach all Activities in the same Application except if you, on pupose, declare Activities to run in different Processes.
See http://developer.android.com/guide/components/processes-and-threads.html