我在线程池中运行了两个线程。我的应用程序在运行后挂起。我可以在线程转储中看到一个线程在MONITOR中,另一个线程处于RUNNING状态。 处于RUNNING状态的线程显示它进入了一个synchronized方法并获得了锁,最后调用了一个本机方法,并停止响应。但它的州显示RUNNING。 处于MONITOR状态的第二个线程被阻塞,等待第一个线程释放MONITOR。我的怀疑是,两个线程都是死锁的,虽然线程转储显示第一个线程正在运行。我怀疑它试图从本机代码中获取一些监视器,而这些监视器无法显示。本机调用中的线程和Java线程是否可能死锁?见下文。 还有一件事。如果我反复运行应用程序,“死锁”#39;如上所述,在代码的各个部分随机出现,而不仅仅是在下面粘贴的内容...通常在Java和Native之间,有时在文件IO操作之间的本机和本机之间(这是可以理解的)。但是Java和Native会陷入僵局吗?感谢。
"pool-1-thread-2@4640" prio=5 tid=0x14 nid=NA runnable
java.lang.Thread.State: RUNNABLE
blocks pool-1-thread-1@4641
at java.lang.Object.clone(Object.java:-1)
at java.util.ResourceBundle$CacheKey.clone(ResourceBundle.java:655)
at java.util.ResourceBundle.putBundleInCache(ResourceBundle.java:1693)
at java.util.ResourceBundle.findBundle(ResourceBundle.java:1477)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1361)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:845)
at com.sun.org.apache.xerces.internal.utils.SecuritySupport$7.run(SecuritySupport.java:169)
at com.sun.org.apache.xerces.internal.utils.SecuritySupport$7.run(SecuritySupport.java:166)
at java.security.AccessController.doPrivileged(AccessController.java:-1)
at com.sun.org.apache.xerces.internal.utils.SecuritySupport.getResourceBundle(SecuritySupport.java:166)
at com.sun.org.apache.xerces.internal.impl.xpath.regex.RegexParser.setLocale(RegexParser.java:99)
at com.sun.org.apache.xerces.internal.impl.xpath.regex.RegexParser.<init>(RegexParser.java:93)
at com.sun.org.apache.xerces.internal.impl.xpath.regex.ParserForXMLSchema.<init>(ParserForXMLSchema.java:41)
at com.sun.org.apache.xerces.internal.impl.xpath.regex.RegularExpression.setPattern(RegularExpression.java:2291)
at com.sun.org.apache.xerces.internal.impl.xpath.regex.RegularExpression.setPattern(RegularExpression.java:2308)
at com.sun.org.apache.xerces.internal.impl.xpath.regex.RegularExpression.<init>(RegularExpression.java:2266)
at com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl.applyFacets(XSSimpleTypeDecl.java:844)
at com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl.applyFacets1(XSSimpleTypeDecl.java:751)
at com.sun.org.apache.xerces.internal.impl.dv.xs.BaseSchemaDVFactory.createBuiltInTypes(BaseSchemaDVFactory.java:208)
at com.sun.org.apache.xerces.internal.impl.dv.xs.SchemaDVFactoryImpl.createBuiltInTypes(SchemaDVFactoryImpl.java:47)
at com.sun.org.apache.xerces.internal.impl.dv.xs.SchemaDVFactoryImpl.<clinit>(SchemaDVFactoryImpl.java:42)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeConstructorAccessorImpl.java:-1)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at com.sun.org.apache.xerces.internal.utils.ObjectFactory.newInstance(ObjectFactory.java:158)
at com.sun.org.apache.xerces.internal.utils.ObjectFactory.newInstance(ObjectFactory.java:143)
at com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory.getInstance(SchemaDVFactory.java:73)
- locked <0x1226> (a java.lang.Class)
at com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory.getInstance(SchemaDVFactory.java:57)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.reset(XMLSchemaLoader.java:1027)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:559)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:538)
at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:255)
at com.fmr.feeds.transformation.XmlProcessor.validateXml(XmlProcessor.java:52)
at com.fmr.feeds.transformation.XmlProcessor.validateInputXML(XmlProcessor.java:34)
at com.fmr.feeds.transformation.Controller.processRecord(Controller.java:99)
at com.fmr.feeds.transformation.Controller.lambda$invokeTransformationService$1(Controller.java:80)
at com.fmr.feeds.transformation.Controller$$Lambda$29.1090160486.run(Unknown Source:-1)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
"pool-1-thread-1@4641" prio=5 tid=0x13 nid=NA waiting for monitor entry
java.lang.Thread.State: BLOCKED
waiting for pool-1-thread-2@4640 to release lock on <0x1226> (a java.lang.Class)
at com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory.getInstance(SchemaDVFactory.java:57)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.reset(XMLSchemaLoader.java:1027)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:559)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:538)
at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:255)
at com.fmr.feeds.transformation.XmlProcessor.validateXml(XmlProcessor.java:52)
at com.fmr.feeds.transformation.XmlProcessor.validateInputXML(XmlProcessor.java:34)
at com.fmr.feeds.transformation.Controller.processRecord(Controller.java:99)
at com.fmr.feeds.transformation.Controller.lambda$invokeTransformationService$1(Controller.java:80)
at com.fmr.feeds.transformation.Controller$$Lambda$29.1090160486.run(Unknown Source:-1)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
答案 0 :(得分:0)
仅通过操作系统(例如争用CPU或文件系统资源)。
本机代码可能会启动未受JVM监视的线程,但JVM中的线程只能从语言角度阻止其他也由JVM管理的线程(除非本机代码非常聪明)
看起来线程pool-1-thread-2@4640
当前正在您的线程转储中执行某些操作。也许等待CPU或OS资源。另一个线程正在等待该线程的调用堆栈中的锁定。