File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Pause in JAVA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Pause in JAVA" Watch "Pause in JAVA" New topic

Pause in JAVA

danesh far

Joined: Nov 25, 2004
Posts: 15
How can I make a pause in my program in java?Could you please give me an example.
Henry Wong

Joined: Sep 28, 2004
Posts: 20373

I don't think there is a guaranteed way to pause a whole program... but you pause a thread of execution with:


The above code is for a 2 second pause.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

Here in the beginner's forum, I'd guess that a "press any key..." kind of pause is what we're after. Use "" to do that.

[Jess in Action][AskingGoodQuestions]
Joel McNary

Joined: Aug 20, 2001
Posts: 1824

...except that instead of "press any key" it has to be "press RETURN to contine" because the standard console doesn't return anything until RETURN has been pushed.

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
I agree. Here's the link:
subject: Pause in JAVA
It's not a secret anymore!