Reputation: 3
This may seem a bit odd, but I need my java program to run slower. I am trying to do lots of math and I am trying to watch it as it does all the math, however, it is computing it to fast and I am getting lost. I want to know if I can slow it down while running or make it compute math slower.
Don't know if this will help but I am using jGrasp and a Windows 7 computer.
Upvotes: 0
Views: 2205
Reputation: 539
as others have stated, you can use breakpoints (best solution) but you could also stick a Scanner#nextLine()
whenever you want to look over your output before proceeding. Thats what I used to do
Upvotes: 0
Reputation: 45741
Just use a debugger. Place a breakpoint on the line your want it to pause on, and you'll be able to see the entire local state when it pauses.
Alternatively, you could just place a sleep statement inside your loop that's running "too fast".
Upvotes: 3
Reputation: 3537
Don't try to slow down your program. If you just want to see the computer do the math, write your output to a file instead of to the console. Then you can read it later.
If you really do just want to slow down your program, use Thread.sleep(msToSleep);
Upvotes: 0
Reputation: 1102
you may want to use Thread.sleep(4000); it pauses your program for 4 seconds
Upvotes: 1
Reputation: 4277
Thread.sleep(***);
after each calculation?
https://docs.oracle.com/javase/tutorial/essential/concurrency/sleep.html
Upvotes: 2