Sebastien BRACQUEMONT added the comment:

Hi Amaury,

to me,Thread objects are meant to be abstract representation of a processing 
that will occur in a separate execution unit at thread start time.
Indeed, that's what the following text (from the link you provided tries to 
explain)

"Once a thread object is created, its activity must be started by calling the 
thread’s start() method. This invokes the run() method in a separate thread of 
control."

So, the 'System Thread' is only created at start() call (which is a good 
implementation choice)
Moreover, the join() method (when completed) will wait for the System Thread to 
be disallocated.

However, the Thread object instance and the processing bound to it are still 
valid.

So in an object oriented point of view, (and syntactically too) , it should be 
valid to reuse the object (and so repeat the processing bound to it) as many 
times as necessary without the need to create a new instance as long as the 
Thread object state is not Alive.

What suprises me , is that the current implementation  of threading.Thread 
(apart from the __started flag behaviour) is compatible with that point of view 
and i see no limitations (apart that bug) preventing such a use of threads.

I think the threading API will provide better 'high-level' view if it didn't 
depend on low level considerations (as the dependency on the existence / 
reusability of the peer System Thread that will be used to effectively host the 
code execution)

Regards,

Sebastien

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

Added file: http://bugs.python.org/file8953/unnamed

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1626>
__________________________________
<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>Hi Amaury,<BR>
&nbsp;<BR>
to me,Thread objects are meant to be <STRONG>abstract</STRONG> representation 
of a processing that will occur in a separate execution unit at thread start 
time.<BR>
Indeed, that's what the following text (from the link you provided tries to 
explain)<BR>
&nbsp;<BR>
"Once a thread object is created, its activity must be started by calling the 
thread’s <TT class="xref docutils literal"><SPAN 
class=pre>start()</SPAN></TT> method. This invokes the <TT class="xref docutils 
literal"><SPAN class=pre>run()</SPAN></TT> method in a separate thread of 
control."<BR>
&nbsp;<BR>
So, the 'System Thread' is only created&nbsp;at start() call (which is a good 
implementation choice)<BR>
Moreover, the join() method (when completed) will wait for the System Thread to 
be disallocated.<BR>
&nbsp;<BR>
However,&nbsp;the Thread object instance and the processing bound to it are 
still valid.<BR>
&nbsp;<BR>
So in an object oriented point of view, (and syntactically too)&nbsp;, it 
should be valid to reuse the object (and so repeat the processing bound to it) 
as many times as necessary without the need to create a new instance as long as 
the Thread object state is not Alive.<BR>
&nbsp;<BR>
What suprises me , is that the current implementation&nbsp; of threading.Thread 
(apart from the __started flag behaviour) is compatible with that point of view 
and i see no limitations (apart that bug) preventing such a use of threads.<BR>
&nbsp;<BR>
I think the threading API will provide better 'high-level' view if it didn't 
depend on low level considerations (as the dependency on the existence / 
reusability of the peer System Thread that will be used to effectively host the 
code execution)<BR>
&nbsp;<BR>
Regards,<BR>
&nbsp;<BR>
Sebastien<BR><BR><BR><BR>

<HR id=stopSpelling>
<BR>
&gt; Subject: [issue1626] threading.Thread objects are not reusable after 
join()<BR>&gt; To: [EMAIL PROTECTED]<BR>&gt; From: [EMAIL PROTECTED]<BR>&gt; 
Date: Fri, 14 Dec 2007 13:03:54 +0000<BR>&gt; <BR>&gt; <BR>&gt; Amaury Forgeot 
d'Arc added the comment:<BR>&gt; <BR>&gt; From the documentation:<BR>&gt; 
http://docs.python.org/dev/library/threading.html#threading.Thread.start<BR>&gt;
 start() must be called at most once per thread object.<BR>&gt; <BR>&gt; I 
think this will not change: when a system thread terminates, you<BR>&gt; cannot 
restart it; you have to create another thread.<BR>&gt; The same argument 
applies to threading.Thread. It would be surprising<BR>&gt; that this object 
can represent multiple system threads.<BR>&gt; <BR>&gt; You should create and 
start different Threads each time.<BR>&gt; <BR>&gt; ----------<BR>&gt; nosy: 
+amaury.forgeotdarc<BR>&gt; resolution: -&gt; invalid<BR>&gt; status: open 
-&gt; closed<BR>&gt; <BR>&gt; __________________________________<BR>&gt; 
Tracker &lt;[EMAIL PROTECTED]&gt;<BR>&gt; 
&lt;http://bugs.python.org/issue1626&gt;<BR>&gt; 
__________________________________<BR><BR><br /><hr />Express yourself 
instantly with MSN Messenger! <a 
href='http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/' target='_new'>MSN 
Messenger</a></body>
</html>
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to