< prev index next >
test/lib/testlibrary/jdk/testlibrary/TestThread.java
Print this page
*** 21,33 ****
* questions.
*/
package jdk.testlibrary;
- import java.lang.management.ManagementFactory;
- import java.lang.management.ThreadInfo;
- import java.lang.management.ThreadMXBean;
import java.util.concurrent.TimeoutException;
/**
* Thread which catches exceptions thrown during the execution
* and stores them for later analysis.
--- 21,30 ----
*** 202,249 ****
if (uncaught != null) {
return uncaught;
}
return null;
}
-
- /**
- * Waits until {@link TestThread} is in the certain {@link State}
- * and blocking on {@code object}.
- *
- * @param state The thread state
- * @param object The object to block on
- */
- public void waitUntilBlockingOnObject(Thread.State state, Object object) {
- String want = object == null ? null : object.getClass().getName() + '@'
- + Integer.toHexString(System.identityHashCode(object));
- ThreadMXBean tmx = ManagementFactory.getThreadMXBean();
- while (isAlive()) {
- ThreadInfo ti = tmx.getThreadInfo(getId());
- if (ti.getThreadState() == state
- && (want == null || want.equals(ti.getLockName()))) {
- return;
- }
- try {
- Thread.sleep(1);
- } catch (InterruptedException e) {
- }
- }
- }
-
- /**
- * Waits until {@link TestThread} is in native.
- */
- public void waitUntilInNative() {
- ThreadMXBean tmx = ManagementFactory.getThreadMXBean();
- while (isAlive()) {
- ThreadInfo ti = tmx.getThreadInfo(getId());
- if (ti.isInNative()) {
- return;
- }
- try {
- Thread.sleep(1);
- } catch (InterruptedException e) {
- }
- }
- }
-
}
--- 199,204 ----
< prev index next >