vaishnavi
04-13-2009, 04:02 AM
Hi all,
I have the following code, but it gives me a run time exception.
Here is my code:
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();
}
}
The run time exception which i am getting is:
Exception in Thread "main" java.lang.IllegalThreadStateException.
Actually it is printing the output "foo" and the above exception follows.
Can anyone tell me why am i getting this error?
I have the following code, but it gives me a run time exception.
Here is my code:
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();
}
}
The run time exception which i am getting is:
Exception in Thread "main" java.lang.IllegalThreadStateException.
Actually it is printing the output "foo" and the above exception follows.
Can anyone tell me why am i getting this error?