0

这是来自转储的单个线程,说明了该问题。没有其他线程持有锁 0x00000007d7f78430 但它仍在等待。

"main" prio=6 tid=0x000000000033b800 nid=0x2478 in Object.wait() [0x000000000257d000]          java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000007d7f78430> (a org.osgi.util.tracker.ServiceTracker$AllTracked)
at org.osgi.util.tracker.ServiceTracker.waitForService(ServiceTracker.java:456)
- locked <0x00000007d7f78430> (a org.osgi.util.tracker.ServiceTracker$AllTracked)
at org.apache.camel.test.blueprint.CamelBlueprintHelper.getOsgiService(CamelBlueprintHelper.java:190)
at org.apache.camel.test.blueprint.CamelBlueprintHelper.getOsgiService(CamelBlueprintHelper.java:165)
at org.apache.camel.test.blueprint.CamelBlueprintTestSupport.createCamelContext(CamelBlueprintTestSupport.java:116)
at org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:247)
at org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:217)
at org.apache.camel.test.blueprint.CamelBlueprintTestSupport.setUp(CamelBlueprintTestSupport.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
4

1 回答 1

1

看一下org.osgi.util.tracker.ServiceTracker.waitForService(long timeout)方法。

您将看到它旨在:

等待此 ServiceTracker 至少跟踪一项服务。

所以这不是锁争用 - 底层系统正在使用锁来等待东西 - 在大多数情况下这实际上是一个非常好的主意。

于 2013-03-15T16:31:54.863 回答