• Post Reply Bookmark Topic Watch Topic
  • New Topic

thread

 
Hung Chang
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which of the following calls will not stop a thread from executin?
assume that the thread is already started.
1.start()
2.notify()
3.wait()
4.interrupt()
5.t.join // here t is some other thread
the answer given is 1,2,3.
can anyone explain why? ^^
 
Jyothi Lature
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hung,
Here is the explanation:
Start() - The start method creates the system resources necessary to run the thread, schedules the thread to run, and calls the thread's run method. So, After the start method has returned, the thread is in "running" state.
notify() - The notify() method wakes up the thread waiting on the object.
wait() - Waits for notification or until the timeout period has elapsed. In this state the thread has not really stopped but waiting to be notified.
So, to conclude none of these methods stop the thread execution, rather they puts the thread into "running" state.
Hope i have answered your question..
have fun,
Jyothi
Originally posted by Hung Chang:
which of the following calls will not stop a thread from executin?
assume that the thread is already started.
1.start()
2.notify()
3.wait()
4.interrupt()
5.t.join // here t is some other thread
the answer given is 1,2,3.
can anyone explain why? ^^

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!