mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fix flaky test
This commit is contained in:
parent
0c8013dfcf
commit
8e4b84545f
|
@ -39,23 +39,21 @@ public class ThreadTest {
|
||||||
public void sleepInterrupted() {
|
public void sleepInterrupted() {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
final Thread mainThread = Thread.currentThread();
|
final Thread mainThread = Thread.currentThread();
|
||||||
new Thread() {
|
new Thread(() -> {
|
||||||
@Override public void run() {
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(50);
|
Thread.sleep(50);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// ok
|
// ok
|
||||||
}
|
}
|
||||||
mainThread.interrupt();
|
mainThread.interrupt();
|
||||||
}
|
}).start();
|
||||||
}.start();
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500);
|
Thread.sleep(5000);
|
||||||
fail("Exception expected");
|
fail("Exception expected");
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
assertEquals(Thread.currentThread(), mainThread);
|
assertEquals(Thread.currentThread(), mainThread);
|
||||||
assertFalse(mainThread.isInterrupted());
|
assertFalse(mainThread.isInterrupted());
|
||||||
assertTrue(System.currentTimeMillis() - start < 150);
|
assertTrue(System.currentTimeMillis() - start < 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user