Search code examples
javatimerwaitsleep

How to wait until timer is stopped in java?


I have a method, which is calling a swing timer to start, and after calling this method, i have to wait until the executed timer stops. I tried

while(timer.isRunning(){}

but it didnt worked, it just froze my program. Please help me and forgive me for my bad english.


Solution

  • As the solution, I used an integer to keep track of the iteration count of my method. When the integer got bigger than a certain number, I knew the time has passed.