Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Exception in thread "main" java.lang.IllegalThreadStateException

807588Apr 28 2009 — edited Apr 28 2009
In the following code snippet , when i run it throws following exception :-
Exception in thread "main" java.lang.IllegalThreadStateException
	at java.lang.Thread.start(Unknown Source)
	at com.collections.Threads4.go(SCJP.java:323)
	at com.collections.Threads4.main(SCJP.java:312)
class Threads4 {
	public static void main (String[] args) {
		new Threads4().go();
	}
	
	public void go() {
		Runnable r = new Runnable() {
			public void run() {
				System.out.print("foo");
			}
		};
		Thread t = new Thread(r);
		t.start();
		t.start();
	}
}
Can anyone let me know why does this happen ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 26 2009
Added on Apr 28 2009
4 comments
180 views