Use sleep instead of yield.
Be less at the mercy of the kernel scheduler and
thread priorities (JIT thread is lower priority).
Test: test.py --jit
Change-Id: I20ccd7ece6ea605ce42f8a16ec23bb377b92e653
diff --git a/test/655-jit-clinit/src/Main.java b/test/655-jit-clinit/src/Main.java
index 5d32180..44b3154 100644
--- a/test/655-jit-clinit/src/Main.java
+++ b/test/655-jit-clinit/src/Main.java
@@ -38,7 +38,12 @@
array = new Object[10000];
while (!Main.isJitCompiled(Foo.class, "hotMethod")) {
Foo.hotMethod();
- Thread.yield();
+ try {
+ // Sleep to give a chance for the JIT to compile `hotMethod`.
+ Thread.sleep(100);
+ } catch (Exception e) {
+ // Ignore
+ }
}
}