can anybody tell me why this code throws an exception?
posted 4 years ago
Perhaps you have got this exception
Exception in thread "main" foojava.lang.IllegalThreadStateException
at java.lang.Thread.start(Unknown Source)
You have started the thread twice. It is never legal to start the thread more than one time. Once the thread completes it's execution it will never restarted.
you can remove the 2nd t.start(); from code.