Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

When the execution ends?  RSS feed

 
Phillipe Rodrigues
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

When run() method returns,the thread has finished its task and is considered dead. There is no way out of this state.Once
a thread is dead,it may not be started again;if you want the thread's task to be performed again,you have to construct
and start a new thread instance. The dad thread continues to exists;it is an object like ay other object and you can still
access its daa and call it methods.You cant make it run again.

In other words:
1. You cant restart a dead thread.
2. You can call the methods of a dead thread.



I tried an examples as below:
1. Implementing a Runnable interface:



2. Extending a Thread class



Help me to better understand the concept that is above italicize paragraph.
 
Henry Wong
author
Sheriff
Posts: 22840
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this...



This codes will run the thread (as previous), wait for the thread to finish, and then try to restart the thread -- which should fail.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!