Programming Tutorials

Comment on Tutorial - A simple Thread sample in Java By Henry



Comment Added by : DeeNKHAN

Comment Added at : 2013-03-02 06:54:13

Comment on Tutorial : A simple Thread sample in Java By Henry
class Foo implements Runnable{

public void run() {
for(int i=0;i<3;i++)

System.out.println("Run by..."+Thread.currentThread().getName()+",i Is "+ i);
}
public void run(String name){

System.out.println("This is Second"+name);
}
}
public class TestingThread {

public static void main(String args [])
{
Foo f = new Foo();
Thread t = new Thread(f);
try {
System.out.println("Number Will be printt After 5 Second..");
for(int j=0;j<5;j++){
System.out.println("This is j..."+j);

t.sleep(5000);
}
}
catch(InterruptedException e) {
System.out.println("InterruptedException.."+ e);
e.printStackTrace();
}
}
}


View Tutorial