hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java
changeset 2526 39a58a50be35
parent 1 489c9b5090e2
child 3261 c7d5aae8d3f7
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java	Fri Apr 03 15:59:19 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java	Mon Apr 06 15:47:39 2009 -0700
@@ -164,20 +164,11 @@
             }
         }
 
-        long leastDiff = 0;
-        boolean leastDiffInitialized = false;
-        JavaThread theOwner = null;
         for (JavaThread thread = first(); thread != null; thread = thread.next()) {
-            Address addr = thread.highestLock();
-            if (addr == null || addr.lessThan(o)) continue;
-            long diff = addr.minus(o);
-            if (!leastDiffInitialized || diff < leastDiff) {
-                leastDiffInitialized = true;
-                leastDiff = diff;
-                theOwner = thread;
-            }
+          if (thread.isLockOwned(o))
+            return thread;
         }
-        return theOwner;
+        return null;
     }
 
     public JavaThread owningThreadFromMonitor(ObjectMonitor monitor) {