Gaurav,
Here is my two cents worth...
Yes, this will work.
Here, we are creating an anonymous class implementing the Runnable
interface. Note the run method that has been implemented which calls
the Work.doIt(). Hence the thread will execute the doIt method.
Nope. This will not work. When you implement a thread by extending the Thread
class, you are required to override the run() method and not the start method.
I know one might argue because we have an overridden version of start() method
here, t.start will execute Work.doIt(). But the catch is, it will be just a
normal synchronous method invocation, and
it will not start a new thread of
execution.
Nope.
This answer will trick you into thinking it might be the right one. Look
carefully - though we are implementing a Runnable interface, you are not
creating a new Thread object. Runnable only defines the run() method
and hence this code will not even compile!
Nope.
Wrong syntax. We don't know if Work extends thread, and even if it does,
we only know it contains a static method doIt(). We are not sure if it
implements the run() method. Too many things to assume.....
Nope.
This is not the correct way of starting a new thread. Though the first
part of setting up the run method is done correctly here, note that no
thread objects are created!
Hope this helps. If not, feel free to ask for more
Ajith