File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes Thread.sleep(3600000) is =  minute ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread.sleep(3600000) is =  minute ?" Watch "Thread.sleep(3600000) is =  minute ?" New topic
Author

Thread.sleep(3600000) is = minute ?

smart smart
Greenhorn

Joined: May 29, 2008
Posts: 4
Hi
i am new baby for java
what is Thread.sleep(3600000) = minute ?
any math formula can tell?
Thank for helping
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"smart smart",
Welcome to the ranch!
Please check your private messages.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

The argument to the sleep method, you have shown is in milliseconds.
1000 milliseconds = 1 seconds
60 seconds = 1 minute

I think you get the formula now


apigee, a better way to API!
Ray Hsieh
Ranch Hand

Joined: Sep 20, 2000
Posts: 59
There's an easier way, just use the TimeUnit enumeration from java.util.concurrent.

To make a thread sleep for 1 minute, you do something like this:

TimeUnit.MINUTES.sleep(1);

To make it sleep for 30 seconds:

TimeUnit.SECONDS.sleep(30);

And so on.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Ray Hsieh:
There's an easier way, just use the TimeUnit enumeration from java.util.concurrent.


Yes, that's an excellent solution, but note that there's no MINUTE member. There's SECOND, MICROSECOND, NANOSECOND, and such, but no MINUTE.


[Jess in Action][AskingGoodQuestions]
Ray Hsieh
Ranch Hand

Joined: Sep 20, 2000
Posts: 59
Actually, there is, if we're talking about Java 6.

http://java.sun.com/javase/6/docs/api/java/util/concurrent/TimeUnit.html

It even has DAYS!
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

I stand corrected. Us old-timers, what do we know...
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18999
    
  40

I guess I am an old-timer too... but isn't 3600000 = one hour?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
yao fan
Greenhorn

Joined: Mar 02, 2008
Posts: 1
I think this is you want to know.
1 s = 1000 ms
1 m = 60 s
1 h = 60 m
 
 
subject: Thread.sleep(3600000) is = minute ?