File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stopping Thread From Execution

 
Sahul Yasin
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
What can cause a thread to stop executing?
1) The program exits via a call to System.exit(0);
2) Another thread is given a higher priority
3) A call to the wait() method.
4) A call to the thread's join() method.
5) A call to the thread's sleep() method.
6) Power off the PC
7) All of the above
 
Jonathan Oblea
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I think the answer is 7) All of the above.
Because the question is "what CAN cause" and all of the options
are possible reasons why a thread can stop its execution.
Regards,
 
Sahul Yasin
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jonathan,
Can join() method able to stop the thread of execution?.
I confused little in this.
 
Jonathan Oblea
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Yes, a call to join() is guaranteed to cause the current thread to stop executing until the thread it joins with completes.
Regards,
 
Sahul Yasin
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jonathan,I read once again K&B threading chapter and clear now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic