David Newton wrote:Did you read its documentation? It supports chained calls.
saima kanwal wrote:Hi Thanvi,
consider the following code:
the output is : ThreadMain
ThreadA (100 times)
Back in ThreadMain
Hope you understand by this simple code.
Neha Daga wrote:because anyways two will always be an object of class Thread.
after starting it it becomes a thread of execution but what after its run method completes??? Do you think the Thread object doesn't exist anymore???
If yes you are wrong, It will still be a Thread object its just it can't be a thread of execution anymore.
hope that clears your doubt.
Simran Dass wrote:
When you just say
Thread two = new Thread(runnable ref);
its a Thread Object. Only after you start it (two.start()) , it becomes a Thread of execution.
Guido Sautter wrote:A look at the JavaDoc of Thread might be pretty helpful here.
Basically, wait() and notify() belong to class Object because myObject.wait() causes the calling thread to wait until some other thread calls myObject.notify() or myObject.notifyAll(). join(), in turn, belongs to class Thread because myThread.join() makes the calling thread wait until myThread dies.