Here you can find the source of sleepFor(long millis)
Parameter | Description |
---|---|
millis | Amount of milliseconds to sleep |
public static void sleepFor(long millis)
//package com.java2s; /**/*from ww w.j a va2s .c om*/ * Copyright (C) 2011,2012 Gordon Fraser, Andrea Arcuri and EvoSuite * contributors * * This file is part of EvoSuite. * * EvoSuite is free software: you can redistribute it and/or modify it under the * terms of the GNU Public License as published by the Free Software Foundation, * either version 3 of the License, or (at your option) any later version. * * EvoSuite is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Public License for more details. * * You should have received a copy of the GNU Public License along with * EvoSuite. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Sleeps at least until the specified amount of time has passed, uninterruptibly. * * @param millis Amount of milliseconds to sleep */ public static void sleepFor(long millis) { sleepUntil(System.currentTimeMillis() + millis); } /** * Sleeps at least until the specified time point has passed. * * (Thread.sleep() does something similar, but can stop sleeping before * the specified time point has passed if the thread is interrupted.) * * @param targetTimeMillis Target time in milliseconds */ public static void sleepUntil(long targetTimeMillis) { while (true) { long delta = targetTimeMillis - System.currentTimeMillis(); if (delta <= 0) { break; } try { Thread.sleep(delta); } catch (InterruptedException e) { /* OK */ } } } }