lahiru nanayakkara wrote: No,I mean we cannot assign thread object to "t1" variable.why is that?
Thread t1=new Thread();
Ok, I'm guessing you mean why we 'shouldn't' ( more on the lines of why it is pointless ) do the declarations such as the one you have mentioned. This is because the default run method in the Thread class does nothing. Of course you created the thread so it does something for you.
But if a Thread is created by passing a Runnable ( a Thread is a Runnable, and a Thread subclass - although it is a bad design at least in this context - is also a Runnable ) to its constructor, and this Runnable overrides the
method thereby specifying what instructions the Thread should execute once it is started, it makes sense to create a Thread.
Consider going through
this page.
Edit : And just to emphasize what Tony said - it IS perfectly legal to create a Thread like this.
Just it does nothing after you start it. It finishes immediately.