我知道JavaScript设计不支持多线程,但是我们使用JavaScript代码就像服务一样,我们使用Nashorn编译JavaScript代码并从编译的脚本实例中同时调用其中一个方法,使用不同的输入获得所需的输出。我们的JavaScript代码是线程安全的,它们永远不会访问或操纵任何全局数据,也不会进行闭包操作。
偶尔,其中一个线程会陷入WeekHashMap并永远阻塞所有其他并发线程。截至目前,我们没有任何解决方法或解决方案,因为WeekHashMap :: getEntry()方法陷入紧密循环,无法中断并安全地终止该线程。这迫使我们不时地反弹,这也降低了Nashorn在一级高收入系统中的收养。
线程转储:
"Thread-3" #7647 prio=5 os_prio=0 tid=0x00007f023c2d0800 nid=0x9384 runnable [0x00007f03feee9000]
java.lang.Thread.State: RUNNABLE
at java.util.WeakHashMap.getEntry(WeakHashMap.java:431)
at java.util.WeakHashMap.containsKey(WeakHashMap.java:417)
at jdk.nashorn.internal.runtime.PropertyListeners$WeakPropertyMapSet.contains(PropertyListeners.java:217)
at jdk.nashorn.internal.runtime.PropertyListeners.containsListener(PropertyListeners.java:115)
- locked <0x000000063c9ecd68> (a jdk.nashorn.internal.runtime.PropertyListeners)
at jdk.nashorn.internal.runtime.PropertyListeners.addListener(PropertyListeners.java:95)
at jdk.nashorn.internal.runtime.PropertyMap.addListener(PropertyMap.java:247)
at jdk.nashorn.internal.runtime.ScriptObject.getProtoSwitchPoint(ScriptObject.java:2112)
at jdk.nashorn.internal.runtime.ScriptObject.createEmptyGetter(ScriptObject.java:2409)
at jdk.nashorn.internal.runtime.ScriptObject.noSuchProperty(ScriptObject.java:2353)
at jdk.nashorn.internal.runtime.ScriptObject.findGetMethod(ScriptObject.java:1960)
at jdk.nashorn.internal.runtime.ScriptObject.lookup(ScriptObject.java:1828)
at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:104)
at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:98)
at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176)
at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:154)
at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:253)
at java.lang.invoke.LambdaForm$DMH/1376533963.invokeSpecial_LLIL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$BMH/1644775282.reinvoke(LambdaForm$BMH)
at java.lang.invoke.LambdaForm$MH/1967400458.exactInvoker(LambdaForm$MH)
at java.lang.invoke.LambdaForm$reinvoker/1083020379.dontInline(LambdaForm$reinvoker)
//Trimmed Purposely
"Thread-2" #7646 prio=5 os_prio=0 tid=0x00007f023c2d6800 nid=0x9383 waiting for monitor entry [0x00007f03fefea000]
java.lang.Thread.State: BLOCKED (on object monitor)
at jdk.nashorn.internal.runtime.PropertyListeners.containsListener(PropertyListeners.java:111)
- waiting to lock <0x000000063c9ecd68> (a jdk.nashorn.internal.runtime.PropertyListeners)
at jdk.nashorn.internal.runtime.PropertyListeners.addListener(PropertyListeners.java:95)
at jdk.nashorn.internal.runtime.PropertyMap.addListener(PropertyMap.java:247)
at jdk.nashorn.internal.runtime.ScriptObject.getProtoSwitchPoint(ScriptObject.java:2112)
at jdk.nashorn.internal.runtime.ScriptObject.createEmptyGetter(ScriptObject.java:2409)
at jdk.nashorn.internal.runtime.ScriptObject.noSuchProperty(ScriptObject.java:2353)
at jdk.nashorn.internal.runtime.ScriptObject.findGetMethod(ScriptObject.java:1960)
at jdk.nashorn.internal.runtime.ScriptObject.lookup(ScriptObject.java:1828)
at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:104)
at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:98)
at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176)
at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:154)
at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:253)
at java.lang.invoke.LambdaForm$DMH/1376533963.invokeSpecial_LLIL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$BMH/1644775282.reinvoke(LambdaForm$BMH)
at java.lang.invoke.LambdaForm$MH/1967400458.exactInvoker(LambdaForm$MH)
at java.lang.invoke.LambdaForm$reinvoker/1083020379.dontInline(LambdaForm$reinvoker)
at java.lang.invoke.LambdaForm$MH/363682507.guard(LambdaForm$MH)
at java.lang.invoke.LambdaForm$reinvoker/1083020379.dontInline(LambdaForm$reinvoker)
//Trimmed Purposely
以下错误中报告了几乎类似的问题,但我无法在此错误中+1或添加更多详细信息。如此错误所述,从开发人员系统重现此错误真的很难。 https://bugs.openjdk.java.net/browse/JDK-8146274
问题: