Start United States USA — software The Performance Impact of java.lang. System.getProperty()

The Performance Impact of java.lang. System.getProperty()

88
0
TEILEN

Learn what problems the java.lang.System.getProperty() API can cause and what you can do to fix blocked threads.
Join the DZone community and get the full member experience. ‘java.lang. System.getProperty()’ is a common API used by Java developers to read the System properties that are configured during application startup time. i.e. when you pass “-DappName=buggyApp” as your application’s startup JVM argument, the value of the ‘appName’ system property can be read by invoking the ‘java.lang. System.getProperty()’. Example: When the above method is invoked, ‘buggyApp’ will be returned. However, if ‘java.lang. System.getProperty()’ is used in a critical code path, it has the potential to degrade the application’s performance. In this post let’s discuss what is the performance impact of invoking ‘java.lang. System.getProperty()’, how to mitigate it, and a real-world production problem triggered by this API. ‘java.lang. System. getProperty()’ API underlyingly uses ‘java.util. Hashtable.get()’ API. Please be advised that ‘java.util. Hashtable.get()’ is a synchronized API. It means only one thread can invoke the ‘java.util. Hashtable.get()’ method at any given time. If a new thread tries to invoke ‘java.util. Hashtable.get()’ API when the first thread is still executing it, the new thread will be put in a BLOCKED state. When a thread is in the BLOCKED state, it won’t be able to progress forward.

Continue reading...