From 8e4b84545fe771a4def1f540edda8f6bb7bb4796 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sun, 7 Jan 2018 16:04:38 +0300 Subject: [PATCH] Fix flaky test --- .../teavm/classlib/java/lang/ThreadTest.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/src/test/java/org/teavm/classlib/java/lang/ThreadTest.java b/tests/src/test/java/org/teavm/classlib/java/lang/ThreadTest.java index 477ee0a03..ae7b4ff41 100644 --- a/tests/src/test/java/org/teavm/classlib/java/lang/ThreadTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/lang/ThreadTest.java @@ -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() { - try { - Thread.sleep(50); - } catch (InterruptedException e) { - // ok - } - mainThread.interrupt(); + new Thread(() -> { + try { + Thread.sleep(50); + } catch (InterruptedException e) { + // ok } - }.start(); + mainThread.interrupt(); + }).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); } }