• Post Reply Bookmark Topic Watch Topic
  • New Topic

Making java program wait for a specific time  RSS feed

 
Gamb Rockwell
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to make a java program of mine wait for a few seconds. In shell scripts I use the sleep() command but what is the equivalent in java. I am not using threads so I can't use the thread approach.

Thanks
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gamb Rockwell:
I am not using threads so I can't use the thread approach.


Just because you are not creating any threads, doesn't mean there isn't any threads. The "main" thread that starts your program is still a thread, and can be put to sleep by calling Thread.sleep().

Henry
 
Jeff Langr
author
Ranch Hand
Posts: 799
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're always running in at least one thread. Try:



-Jeff-
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!