[M3devel] join twice?

Mika Nystrom mika at async.async.caltech.edu
Tue Nov 3 19:23:19 CET 2009


It seems to me that the AlertJoin "fails" if it is alerted...?  So you
would have to call it (or plain Join) again.

    Mika


Tony Hosking writes:
>
>--Apple-Mail-99--208255775
>Content-Type: text/plain;
>	charset=US-ASCII;
>	format=flowed;
>	delsp=yes
>Content-Transfer-Encoding: 7bit
>
>So, here is a question.  What happens with AlertJoin?  If I get an  
>alert before the join occurs can I rejoin?  It would seem reasonable  
>that I should be able to do so.
>
>Should we simply permit only one joiner at any given time?
>
>On 3 Nov 2009, at 10:16, Tony Hosking wrote:
>
>> The original threads spec for Modula-3 does not mention join can  
>> only run once.  The only mention is in Thread.i3.
>>
>> I agree that it seems silly to join twice.  On the other hand, Java  
>> semantics does not prohibit multiple joins.
>>
>> Antony Hosking | Associate Professor | Computer Science | Purdue  
>> University
>> 305 N. University Street | West Lafayette | IN 47907 | USA
>> Office +1 765 494 6001 | Mobile +1 765 427 5484
>>
>>
>>
>>
>> On 3 Nov 2009, at 10:04, Jay K wrote:
>>
>>>
>>> To me..with a Win32 background..join means "wait for thread to  
>>> finish".
>>>
>>> And there is a separate action "get thread result".
>>>
>>> You could consider these one merged operation "wait for thread to  
>>> finish and get its result".
>>>
>>> In either case, it is reasonable to allow it multiple times.
>>>
>>> Waiting for a thread to finish that has already finished is just  
>>> fast.
>>>
>>> Getting a thread result that you already got is also easy albeit  
>>> usually unnecessary.
>>>
>>>
>>>
>>> Now, if the operation is "wait for thread to finish, get its  
>>> result, and lose track of its result",
>>>
>>> that isn't idempotent.
>>>
>>>
>>>
>>> I'm torn. The existing implementations all either support multiple  
>>> join or have to go out of
>>>
>>> their way to prevent it. Yet Thread.i3 has been commented so  
>>> presumably forever.
>>>
>>>
>>>
>>> - Jay
>>>
>>>
>>>
>>>
>>> Date: Tue, 3 Nov 2009 09:36:23 -0500
>>> From: rcoleburn at scires.com
>>> To: m3devel at elegosoft.com
>>> Subject: Re: [M3devel] join twice?
>>>
>>>
>>> I think the comment in the code is correct.
>>>
>>> Semantically, it doesn't make sense to join a thread more than  
>>> once.  Join is the compliment to Fork.  With fork, one thread  
>>> becomes two.  With Join, two threads become one.  After they've  
>>> become one, the 2nd thread is no more, so you can't join to it  
>>> anymore.
>>>
>>> IMO, the implementation should enforce this behavior.  What would  
>>> be the "benefit" of allowing more than one join?  What does it  
>>> "mean" to join a "dead thread"?
>>>
>>> Regards,
>>> Randy Coleburn
>>>
>>>>>> Tony Hosking <hosking at cs.purdue.edu> 11/2/2009 11:54 PM >>>
>>>
>>>
>>>
>>>
>>> OK, sure.  Fair enough.
>>>
>>>
>>> On 2 Nov 2009, at 16:43, Jay K wrote:
>>>
>>>> (Whether the implementation actually prohibits it or not is an  
>>>> implementation decision.)
>>>
>>> Tony, I'm sympathetic to the smaller version but I think it is wrong.
>>> "It is a checked runtime error to call this more than once for any t"
>>> is a much different/stronger statement than e.g.
>>> "it is implementation defined what happens if you call join more  
>>> than once for any t".
>>> The printed Reactor 4.1 docs have the same comment as current  
>>> Thread.i3.
>>>
>>> You know, ideally if I write:
>>> Thread.Join(t);
>>> Thread.Join(t);
>>>
>>> and it works today on any system, it will continue to work on all  
>>> systems
>>
>
>
>--Apple-Mail-99--208255775
>Content-Type: text/html;
>	charset=US-ASCII
>Content-Transfer-Encoding: quoted-printable
>
><html><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
>-webkit-line-break: after-white-space; ">So, here is a question. =
> What happens with AlertJoin?  If I get an alert before the =
>join occurs can I rejoin?  It would seem reasonable that I should =
>be able to do so.<div><br></div><div>Should we simply permit only one =
>joiner at any given time?<br><div><br></div><div><div>On 3 Nov 2009, at =
>10:16, Tony Hosking wrote:</div><div><div><br =
>class=3D"Apple-interchange-newline"><blockquote type=3D"cite"><div =
>style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
>-webkit-line-break: after-white-space; ">The original threads spec for =
>Modula-3 does not mention join can only run once.  The only mention =
>is in Thread.i3.<div><br></div><div>I agree that it seems silly to join =
>twice.  On the other hand, Java semantics does not prohibit =
>multiple joins.<br><div><br><div> <span class=3D"Apple-style-span" =
>style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
>Helvetica; font-size: 12px; font-style: normal; font-variant: normal; =
>font-weight: normal; letter-spacing: normal; line-height: normal; =
>orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; =
>white-space: normal; widows: 2; word-spacing: 0px; =
>-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
>0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
>auto; -webkit-text-stroke-width: 0; "><div style=3D"word-wrap: =
>break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
>after-white-space; "><span class=3D"Apple-style-span" =
>style=3D"border-collapse: separate; -webkit-border-horizontal-spacing: =
>0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); =
>font-family: Helvetica; font-size: 12px; font-style: normal; =
>font-variant: normal; font-weight: normal; letter-spacing: normal; =
>line-height: normal; -webkit-text-decorations-in-effect: none; =
>text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; =
>orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div =
>style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
>-webkit-line-break: after-white-space; "><span class=3D"Apple-style-span" =
>style=3D"border-collapse: separate; -webkit-border-horizontal-spacing: =
>0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); =
>font-family: Helvetica; font-size: 12px; font-style: normal; =
>font-variant: normal; font-weight: normal; letter-spacing: normal; =
>line-height: normal; -webkit-text-decorations-in-effect: none; =
>text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; =
>orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span =
>class=3D"Apple-style-span" style=3D"border-collapse: separate; =
>-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
>0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
>font-style: normal; font-variant: normal; font-weight: normal; =
>letter-spacing: normal; line-height: normal; =
>-webkit-text-decorations-in-effect: none; text-indent: 0px; =
>-webkit-text-size-adjust: auto; text-transform: none; orphans: 2; =
>white-space: normal; widows: 2; word-spacing: 0px; "><span =
>class=3D"Apple-style-span" style=3D"border-collapse: separate; =
>-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
>0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
>font-style: normal; font-variant: normal; font-weight: normal; =
>letter-spacing: normal; line-height: normal; =
>-webkit-text-decorations-in-effect: none; text-indent: 0px; =
>-webkit-text-size-adjust: auto; text-transform: none; orphans: 2; =
>white-space: normal; widows: 2; word-spacing: 0px; "><span =
>class=3D"Apple-style-span" style=3D"border-collapse: separate; =
>-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
>0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
>font-style: normal; font-variant: normal; font-weight: normal; =
>letter-spacing: normal; line-height: normal; =
>-webkit-text-decorations-in-effect: none; text-indent: 0px; =
>-webkit-text-size-adjust: auto; text-transform: none; orphans: 2; =
>white-space: normal; widows: 2; word-spacing: 0px; "><span =
>class=3D"Apple-style-span" style=3D"border-collapse: separate; =
>-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
>0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
>font-style: normal; font-variant: normal; font-weight: normal; =
>letter-spacing: normal; line-height: normal; =
>-webkit-text-decorations-in-effect: none; text-indent: 0px; =
>-webkit-text-size-adjust: auto; text-transform: none; orphans: 2; =
>white-space: normal; widows: 2; word-spacing: 0px; "><span =
>class=3D"Apple-style-span" style=3D"border-collapse: separate; =
>-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
>0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
>font-style: normal; font-variant: normal; font-weight: normal; =
>letter-spacing: normal; line-height: normal; =
>-webkit-text-decorations-in-effect: none; text-indent: 0px; =
>-webkit-text-size-adjust: auto; text-transform: none; orphans: 2; =
>white-space: normal; widows: 2; word-spacing: 0px; "><span =
>class=3D"Apple-style-span" style=3D"border-collapse: separate; =
>-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
>0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
>font-style: normal; font-variant: normal; font-weight: normal; =
>letter-spacing: normal; line-height: normal; =
>-webkit-text-decorations-in-effect: none; text-indent: 0px; =
>-webkit-text-size-adjust: auto; text-transform: none; orphans: 2; =
>white-space: normal; widows: 2; word-spacing: 0px; "><span =
>class=3D"Apple-style-span" style=3D"border-collapse: separate; =
>-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
>0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
>font-style: normal; font-variant: normal; font-weight: normal; =
>letter-spacing: normal; line-height: normal; =
>-webkit-text-decorations-in-effect: none; text-indent: 0px; =
>-webkit-text-size-adjust: auto; text-transform: none; orphans: 2; =
>white-space: normal; widows: 2; word-spacing: 0px; "><div><font =
>class=3D"Apple-style-span" color=3D"#0000FF"><font =
>class=3D"Apple-style-span" face=3D"Gill Sans"><span =
>class=3D"Apple-style-span" style=3D"color: rgb(0, 0, 255); font-family: =
>'Gill Sans'; "><span class=3D"Apple-style-span" style=3D"color: rgb(0, =
>0, 255); font-family: 'Gill Sans'; ">Antony =
>Hosking</span></span></font></font><font class=3D"Apple-style-span" =
>face=3D"Gill Sans"><span class=3D"Apple-style-span" style=3D"font-family: =
>'Gill Sans'; "><span class=3D"Apple-style-span" style=3D"font-family: =
>'Gill Sans'; "><span class=3D"Apple-converted-space"> </span>|<span =
>class=3D"Apple-converted-space"> </span></span></span><span =
>class=3D"Apple-style-span" style=3D"font-family: 'Gill Sans'; "><span =
>class=3D"Apple-style-span" style=3D"font-family: 'Gill Sans'; =
>">Associate Professor</span></span><span class=3D"Apple-style-span" =
>style=3D"font-family: 'Gill Sans'; "><span class=3D"Apple-style-span" =
>style=3D"font-family: 'Gill Sans'; "> | Computer Science | Purdue =
>University</span></span></font></div><div><font class=3D"Apple-style-span"=
> face=3D"GillSans-Light"><span class=3D"Apple-style-span" =
>style=3D"font-family: GillSans-Light; ">305 N. University Street | West =
>Lafayette | IN 47907 | USA</span></font></div><div><font =
>class=3D"Apple-style-span" color=3D"#0000FF" face=3D"Gill Sans"><span =
>class=3D"Apple-style-span" style=3D"color: rgb(0, 0, 255); font-family: =
>'Gill Sans'; "><span class=3D"Apple-style-span" style=3D"color: rgb(0, =
>0, 255); font-family: 'Gill Sans'; ">Office</span></span></font><font =
>class=3D"Apple-style-span" face=3D"GillSans-Light"><span =
>class=3D"Apple-style-span" style=3D"font-family: GillSans-Light; "><span =
>class=3D"Apple-style-span" style=3D"font-family: GillSans-Light; =
>"> +1 765 494 6001 |<span =
>class=3D"Apple-converted-space"> </span></span></span></font><font =
>class=3D"Apple-style-span" color=3D"#0000FF" face=3D"Gill Sans"><span =
>class=3D"Apple-style-span" style=3D"color: rgb(0, 0, 255); font-family: =
>'Gill Sans'; "><span class=3D"Apple-style-span" style=3D"color: rgb(0, =
>0, 255); font-family: 'Gill Sans'; ">Mobile</span></span></font><font =
>class=3D"Apple-style-span" face=3D"GillSans-Light"><span =
>class=3D"Apple-style-span" style=3D"font-family: GillSans-Light; "><span =
>class=3D"Apple-style-span" style=3D"font-family: GillSans-Light; "><span =
>class=3D"Apple-converted-space"> </span>+1 765 427 =
>5484</span></span></font></div><div><font class=3D"Apple-style-span" =
>face=3D"GillSans-Light"><br =
>class=3D"khtml-block-placeholder"></font></div></span></span></span></span=
>></span></span></span><br =
>class=3D"Apple-interchange-newline"></span></div></span></div></span><br =
>class=3D"Apple-interchange-newline"> </div><br><div><div>On 3 Nov 2009, =
>at 10:04, Jay K wrote:</div><br =
>class=3D"Apple-interchange-newline"><blockquote type=3D"cite"><div><br>To =
>me..with a Win32 background..join means "wait for thread to =
>finish".<br><br>And there is a separate action "get thread =
>result".<br><br>You could consider these one merged operation "wait for =
>thread to finish and get its result".<br><br>In either case, it is =
>reasonable to allow it multiple times.<br><br>Waiting for a thread to =
>finish that has already finished is just fast.<br><br>Getting a thread =
>result that you already got is also easy albeit usually =
>unnecessary.<br><br><br><br>Now, if the operation is "wait for thread to =
>finish, get its result, and lose track of its result",<br><br>that isn't =
>idempotent.<br><br><br><br>I'm torn. The existing implementations all =
>either support multiple join or have to go out of<br><br>their way to =
>prevent it. Yet Thread.i3 has been commented so presumably =
>forever.<br><br><br><br> - Jay<br><br><br><br><br>Date: Tue, 3 Nov 2009 =
>09:36:23 -0500<br>From: <a =
>href=3D"mailto:rcoleburn at scires.com">rcoleburn at scires.com</a><br>To: <a =
>href=3D"mailto:m3devel at elegosoft.com">m3devel at elegosoft.com</a><br>Subject=
>: Re: [M3devel] join twice?<br><br><br>I think the comment in the code =
>is correct.<br><br>Semantically, it doesn't make sense to join a thread =
>more than once.  Join is the compliment to Fork.  With fork, =
>one thread becomes two.  With Join, two threads become one. =
> After they've become one, the 2nd thread is no more, so you can't =
>join to it anymore.<br><br>IMO, the implementation should enforce this =
>behavior.  What would be the "benefit" of allowing more than one =
>join?  What does it "mean" to join a "dead =
>thread"?<br><br>Regards,<br>Randy Coleburn<br><br><blockquote =
>type=3D"cite"><blockquote type=3D"cite"><blockquote type=3D"cite">Tony =
>Hosking <<a =
>href=3D"mailto:hosking at cs.purdue.edu">hosking at cs.purdue.edu</a>> =
>11/2/2009 11:54 PM =
>>>><br></blockquote></blockquote></blockquote><br><br><br><br>OK,=
> sure.  Fair enough.<br><br><br>On 2 Nov 2009, at 16:43, Jay K =
>wrote:<br><br><blockquote type=3D"cite">(Whether the implementation =
>actually prohibits it or not is an implementation decision.) =
> <br></blockquote><br>Tony, I'm sympathetic to the smaller version =
>but I think it is wrong.<br>"It is a checked runtime error to call this =
>more than once for any t"<br>is a much different/stronger statement than =
>e.g.<br>"it is implementation defined what happens if you call join more =
>than once for any t".<br>The printed Reactor 4.1 docs have the same =
>comment as current Thread.i3.<br><br>You know, ideally if I =
>write:<br>Thread.Join(t);<br>Thread.Join(t);<br><br>and it works today =
>on any system, it will continue to work on all =
>systems</div></blockquote></div><br></div></div></div></blockquote></div><=
>br></div></div></div></body></html>=
>
>--Apple-Mail-99--208255775--



More information about the M3devel mailing list