This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 18538

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: 24183

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: 1817

...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
Similar Threads
wait method doesn't working.
'.dat' file Question.
Execution from .bat file
Starting Java from .bat file