0
在多線程應用程序中,我使用偉大的Apache Commons庫。 但是,由於某種原因,我的一半線程在調用其getList及類似方法時被阻止。Apache Commons - ConfigurationInterpolator阻止線程
這是threadump的樣品:
java.lang.Thread.State: BLOCKED (on object monitor)
at org.apache.commons.configuration.interpol.ConfigurationInterpolator. (ConfigurationInterpolator.java:138)
- locked <0x00000000855e6138> (a java.util.HashMap)
at org.apache.commons.configuration.AbstractConfiguration.createInterpolator(AbstractConfiguration.java:328)
at org.apache.commons.configuration.AbstractConfiguration.getSubstitutor(AbstractConfiguration.java:292)
- locked <0x00000000d7293058> (a org.apache.commons.configuration.SubsetConfiguration)
at org.apache.commons.configuration.PropertyConverter.interpolate(PropertyConverter.java:958)
at org.apache.commons.configuration.AbstractConfiguration.interpolate(AbstractConfiguration.java:446)
at org.apache.commons.configuration.SubsetConfiguration.interpolate(SubsetConfiguration.java:213)
at org.apache.commons.configuration.SubsetConfiguration.interpolate(SubsetConfiguration.java:218)
at org.apache.commons.configuration.AbstractConfiguration.interpolate(AbstractConfiguration.java:433)
at org.apache.commons.configuration.SubsetConfiguration.interpolate(SubsetConfiguration.java:224)
at org.apache.commons.configuration.AbstractConfiguration.getString(AbstractConfiguration.java:1039)
at org.apache.commons.configuration.AbstractConfiguration.getString(AbstractConfiguration.java:1018)
每次一個線程被阻塞(由的GetList或getInt或類似的方法)的鎖處於ConfigurationInterplator類。 通過查看它的源代碼,我明白該類的實例化是同步的 - 但是我只需要能夠讀取屬性,並且不需要每次插值。
Apache Commons中是否有構建方法來克服此限制?例如,不要每次都進行插值步驟並以某種方式緩存它?
感謝, krisy