File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

threads

 
Sahil Manchanda
Ranch Hand
Posts: 41
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody tell me why this code throws an exception?

 
Sharmistha Sarkar
Ranch Hand
Posts: 49
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might also be interested in learning about the lifecycle of threads
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic