aspose file tools*
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
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: 19070
    
  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: 24187
    
  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: 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: http://aspose.com/file-tools
 
subject: Pause in JAVA