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