Jump to content

Malcolm

Global Moderator
  • Posts

    146278
  • Joined

  • Last visited

  • Days Won

    21
  • Feedback

    100%

Everything posted by Malcolm

  1. easy public static void main(String[] args) { conditionalSleep(() -> false, 5_000); } public static void conditionalSleep(BooleanSupplier condition, long sleepTime) { final long startTime = System.currentTimeMillis(); do { if (System.currentTimeMillis() >= startTime + sleepTime) { break; } try { Thread.sleep(10); } catch (InterruptedException e) { } } while (!condition.getAsBoolean()); }
×
×
  • Create New...