Results 1 to 5 of 5
Thread: static void sleep()
- 09-11-2012, 12:58 PM #1
static void sleep()
According to the API specification the method sleep(long millis, int nanos) in the Thread class is overloaded, so that an long argument will execute the method with millis and and int argument will execute the sleep method with nanos. My question is, when I execute something like
Java Code:Thread.currentThread().sleep(500);
- 09-11-2012, 02:15 PM #2
Re: static void sleep()
Huh? The overload you refer to takes two arguments.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 09-15-2012, 01:30 PM #3
Re: static void sleep()
Yes, this is the content and description of the sleep method in the java api 7. you must read it as either a long is passed OR a an int and not both! but the question is: a long argument will execute the method with millis and a call with an int argument will execute the sleep method with nanos. My question is, when I execute something like
Thread.currentThread().sleep(500);
the value 500 is an int and the method should run with 500 nanos. But when I look at the behavior of the executed code the 500 are interpreted as millis. Does that mean that the 500 are interpreted as a long value? Hope you get my question.
- 09-15-2012, 02:15 PM #4
Re: static void sleep()
There's only one overload of sleep(...) that takes a single argument, and that argument is of type long and represents a millisecond value.
There is no overload of sleep(...) that takes a single int argument.
There is an overload of sleep(...) that takes two arguments, a long that represents milliseconds and an int that represents nanoseconds.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 09-15-2012, 11:40 PM #5
Re: static void sleep()
ok, my question is already anwered.
Similar Threads
-
Q?> about public static void main(String args[])
By boblingwide in forum New To JavaReplies: 4Last Post: 03-23-2012, 12:17 PM -
What is the difference between Public Static Void and Public Void?
By whateverme in forum New To JavaReplies: 1Last Post: 12-04-2010, 06:41 PM -
Public static void main (String args[])
By arefeh in forum New To JavaReplies: 12Last Post: 01-28-2010, 12:58 PM -
The different of static void,protected,and void in methods?
By Winarto in forum New To JavaReplies: 5Last Post: 01-25-2008, 12:53 AM
Bookmarks