Change the java code below to handle interrupted exceptions, and also to input the integer to multiply by sleeptime.   public class SleepUtilities {      /**  * Nap between zero and NAP_TIME seconds.    */      public static void nap() {            nap(NAP_TIME);      }        /**  * Nap between zero and duration seconds.    */      public static void nap(int duration) {            int sleeptime = (int) (NAP_TIME * Math.random() );            try { Thread.sleep(sleeptime*1000); }            catch (InterruptedException e) {}      }        private static final int NAP_TIME = 5;

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

Change the java code below to handle interrupted exceptions, and also to input the integer to multiply by sleeptime.

 

public class SleepUtilities

{

     /**  * Nap between zero and NAP_TIME seconds.    */

     public static void nap() {

           nap(NAP_TIME);

     }

 

     /**  * Nap between zero and duration seconds.    */

     public static void nap(int duration) {

           int sleeptime = (int) (NAP_TIME * Math.random() );

           try { Thread.sleep(sleeptime*1000); }

           catch (InterruptedException e) {}

     }

 

     private static final int NAP_TIME = 5;

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
InputStream
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT