John Greenauer

Greenhorn
+ Follow
since Jun 29, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by John Greenauer

Ahh. Yes, that does work. I haven't gotten to "this" in my book yet. I see that it stops printing "Action" without stopping the program. I can see how that's probably a better option in most cases. Thanks a lot.
14 years ago
O.K. I finally got it. That definitely took longer than it should have.

I was getting an error message with timer.cancel(); , but System.exit(0); worked straight off. I've put the final product below for any rookies (like me) that might look for it.

Thanks for the help.

14 years ago
Thanks for your reply

I'm not having much success with that. The code below causes "Action to be print 5 times immediately, every second (after the 1 second delay). I believe that the 1 second delay in the timer method does not prevent the computer from running through the for loop quickly. So, 5 timers are created in less than a second and they all activate after the one second delay. Also, if the timer.cancel(); is un-commented, the program prints nothing because it ends before the one second delay has run it's course. I've tried a slightly different version of this with the timer.cancel(); placed within an if( count == 4) loop. It also prints nothing.

Perhaps the timer method will not work the way I want it to. Maybe, I need a different method. Any thoughts?



14 years ago
Hi,

This is my first post here, so please bear with me.

I want to make my simple program print "Action" 5 times and then stop. The code below will print "Action" once per second forever. If I un-comment the timer.cancel(); it stops before it even prints once. I've tried putting the timer inside a for loop and inside a while loop, but can't make them work.

What am I missing?

Thanks in advance.

- Johnny

14 years ago