Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2012
    Rep Power

    Default A question of calculation

    Hi all

    I am new to Java which is why i am posting here...

    I have a thread that throws 5000 at the code below...

    Java Code:
    double slpAmnt = (double)Math.random()*5000; // work out sleep amount
    try	{
    	sleep((long)slpAmnt);// sleep for sleep amount
    catch (Exception e1) {
    I would very much appreciate advice on what the emboldened code does with 5000?

    I think i understand the Math.random()*5000 produces anything in the range of 0 to 5000, but am unsure what the rest does?

    Many thanks for any replies
    Last edited by DarrylBurke; 01-25-2012 at 06:28 AM. Reason: Removed silly [B] tags used within the code tags

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: A question of calculation

    Try reading the API doc for the sleep() method to see what it does.
    Java Platform SE 6

Similar Threads

  1. Replies: 13
    Last Post: 08-19-2011, 01:23 AM
  2. Calculation with char
    By chuckbalzer in forum New To Java
    Replies: 7
    Last Post: 09-20-2010, 06:29 PM
  3. Help with the calculation of a variable.
    By rarschach in forum New To Java
    Replies: 14
    Last Post: 01-24-2010, 03:50 PM
  4. Problem with Calculation ....
    By danny000 in forum New To Java
    Replies: 1
    Last Post: 04-15-2008, 03:42 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts