equal
deleted
inserted
replaced
162 if (o.equals(thread.threadObjectAddress())) { |
162 if (o.equals(thread.threadObjectAddress())) { |
163 return thread; |
163 return thread; |
164 } |
164 } |
165 } |
165 } |
166 |
166 |
167 long leastDiff = 0; |
167 for (JavaThread thread = first(); thread != null; thread = thread.next()) { |
168 boolean leastDiffInitialized = false; |
168 if (thread.isLockOwned(o)) |
169 JavaThread theOwner = null; |
169 return thread; |
170 for (JavaThread thread = first(); thread != null; thread = thread.next()) { |
170 } |
171 Address addr = thread.highestLock(); |
171 return null; |
172 if (addr == null || addr.lessThan(o)) continue; |
|
173 long diff = addr.minus(o); |
|
174 if (!leastDiffInitialized || diff < leastDiff) { |
|
175 leastDiffInitialized = true; |
|
176 leastDiff = diff; |
|
177 theOwner = thread; |
|
178 } |
|
179 } |
|
180 return theOwner; |
|
181 } |
172 } |
182 |
173 |
183 public JavaThread owningThreadFromMonitor(ObjectMonitor monitor) { |
174 public JavaThread owningThreadFromMonitor(ObjectMonitor monitor) { |
184 return owningThreadFromMonitor(monitor.owner()); |
175 return owningThreadFromMonitor(monitor.owner()); |
185 } |
176 } |