Creating a thread by implementing Runnable Interface
public class RunnableI {
public static void main(String[] args) {
T t = new T();
t.run();
}
}
class T implements Runnable {
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("THREAD STARTED");
//from here write what you want to do in this thread
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("THREAD ENDED");
}
}
Comments
Post a Comment