<br><br><div class="gmail_quote">2009/4/21 Hans Aberg <span dir="ltr">&lt;<a href="mailto:haberg@math.su.se">haberg@math.su.se</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Is it possible to kill a thread by saving a reference and calling exit() (or something) on that reference? Are there any means by which a created thread can be manipulated from without it by its reference?</blockquote><div>
<br>Like this?<br><br>fun void foo()<br>    {<br>    while(1)<br>        {<br>        &lt;&lt;&lt;&quot;beep&quot;&gt;&gt;&gt;;<br>        second =&gt; now;<br>        }<br>    }<br><br>spork ~foo() @=&gt; Shred bar;<br><br>
3::second =&gt; now;<br><br>bar.exit();<br>second =&gt; now;<br>&lt;&lt;&lt;&quot;bye&quot;&gt;&gt;&gt;;<br><br>Sadly there is currently a bug when we define a Shred object and later assign a actual shred to it; this will crash ChucK. This bug was likely caused by the last update which attempted to clean up the relationship between Shred objects and actual running processes (this wasn&#39;t always a very clear relationship).<br>
<br>You can also have the Shred report it&#39;s number using <a href="http://me.id">me.id</a>() inside that shred and set Machine.remove(int id ) loose on that.<br><br>If this crashing bug bothers you (and it likely will) you can use this construct to get a shred&#39;s id number while sporking it;<br>
&lt;&lt;&lt;(spork ~foo()).id()&gt;&gt;&gt;;<br><br>This integer can then be used with Machine.remove() to remove the shred.<br><br>There are more illustrations in /examples/shred/<br><br>I think that should get you out of trouble? I can&#39;t recommend the /examples/ directory highly enough as a resource.<br>
<br>Yours,<br>Kas.<br><br> </div><br></div><br>