Hey guys, got a question about Java(not javascript).
Is it possible for me to delay the output of a string or char. So for example you run the program and each position in the string is displayed with like a 0.5 second wait after the previous position.
Its for a program in which the user can have a conversation with the program itself, that will be the overall function of the program. So a nice fancy delayed output for what the program syas to you would be a nice little touch.
Cheers
JAVA problem
JAVA problem
Death is the only true freedom, brought on by our own ignorance.... Welcome to the "free" world in which we live...
- bad_brain
- Site Owner
- Posts: 11638
- Joined: 06 Apr 2005, 16:00
- 19
- Location: In your eye floaters.
- Contact:
it´s pretty simple by using the sleep()-method to pause the thread:
http://java.sun.com/j2se/1.3/docs/api/j ... hread.html (in the method summary).
here´s a simple example:
http://java.sun.com/j2se/1.3/docs/api/j ... hread.html (in the method summary).
here´s a simple example:
Code: Select all
public class TSleep extends Thread{
public static void main(String argv[]){
TSleep t = new TSleep();
t.start();
}
public void run(){
try{
while(true){
this.sleep(500);
System.out.println("looping while");
}
}catch(InterruptedException ie){}
}
}