U check out this code ....i suppose this wud be the answer for uor a year long query...
class TestThread
{
public static void main(
String args [])
{
Thread1 t1 = new Thread1();
Thread th1 = new Thread(t1);
Thread th2 = new Thread(t1);
th1.start();th2.start();
}
}// End of TestThread
class Thread1 implements Runnable
{
public void run()
{
int i=0;
while(true)
{
System.out.println("Value of i = " + i++);
if ( i == 10)
break;
}
}
}
The vary reason behind putting uor loop in to infinite one as u have defined uor variable i out side of the run method .
Ashish