This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Thread.sleep(3600000) is = minute ?  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i am new baby for java
what is Thread.sleep(3600000) = minute ?
any math formula can tell?
Thank for helping
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"smart smart",
Welcome to the ranch!
Please check your private messages.
-Ben
 
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
author and iconoclast
Sheriff
Posts: 24220
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Ray Hsieh
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 24220
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I stand corrected. Us old-timers, what do we know...
 
author
Sheriff
Posts: 23586
138
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I am an old-timer too... but isn't 3600000 = one hour?

Henry
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this is you want to know.
1 s = 1000 ms
1 m = 60 s
1 h = 60 m
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!