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
Author

Pause in JAVA

danesh far
Greenhorn

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

Joined: Sep 28, 2004
Posts: 18538
    
  40

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

Thread.sleep(2000);

The above code is for a 2 second pause.

Henry


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

Joined: Jul 08, 2003
Posts: 24183
    
  34

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


[Jess in Action][AskingGoodQuestions]
Joel McNary
Bartender

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: http://aspose.com/file-tools
 
subject: Pause in JAVA
 
Similar Threads
wait method doesn't working.
Pause
'.dat' file Question.
Execution from .bat file
Starting Java from .bat file