Monday, February 23, 2009

Creating a thread by implementing "Runnable" Interface

// Save as "thread_runnable.java"

class t1 implements Runnable
{
public void run() {
for(int i=0;i<=10;i++){
System.out.println("Values -->"+i);
}
}
}

public class thread_runnable {
public static void main(String args[])
{
t1 obj=new t1();
Thread t=new Thread(obj);
t.start();
}
}

No comments:

Post a Comment