Here you can find the source of sleep(long ms)
Parameter | Description |
---|---|
ms | The milliseconds to sleep |
public static boolean sleep(long ms)
//package com.java2s; /*/* ww w . j av a2s .co m*/ * Copyright 2018 ImpactDevelopment * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Sleeps the current thread for the specified length * of time represented as milliseconds without the need * for a try/catch enclosure. * * @see Thread#sleep(long) * * @param ms The milliseconds to sleep * @return Whether or not an {@code InterruptedException} was thrown by {@code Thread#sleep(long)} */ public static boolean sleep(long ms) { if (ms <= 0) { return true; } try { Thread.sleep(ms); return true; } catch (InterruptedException e) { e.printStackTrace(); } return false; } }