-3

I have some code here and it seems to run into an IllegalThreadStateExceptionand I don't know why. By doing this, it runs two codes at the same time. What I am trying to do is that if I enter anything (word, number, character) the countdown will restart. But whenever I enter something before the countdown stops, it always runs to that exception. What am I doing wrong and is there something I can do to correct it?

These are two codes merged in one picture

1 Answers1

0

You can't call start on a thread more than once. When you call start the second time you'll get an IllegalStateException.

Move the initialization of exp to within the for loop so that start is called on a different instance each time.

Nathan Hughes
  • 94,330
  • 19
  • 181
  • 276