I have written this program:
public class ThreadWithNoRunnable {
public static void main(String[] args) {
class MyRunnable implements Runnable {
@Override
public void run() {
System.out.println("This is work getting progressed");
}
}
MyRunnable r = new MyRunnable();
Thread t = new Thread();
t.start();
}
}
I created a Thread object
with zero argument constructor. How do I pass my Runnable object
to this thread t
object, so that it executes run() of MyRunnable
. If this isn't possible,then why we have a zero argument Thread consutuctor?