<br><br><div class="gmail_quote">2009/4/21 Hans Aberg <span dir="ltr"><<a href="mailto:haberg@math.su.se">haberg@math.su.se</a>></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> <<<"beep">>>;<br> second => now;<br> }<br> }<br><br>spork ~foo() @=> Shred bar;<br><br>
3::second => now;<br><br>bar.exit();<br>second => now;<br><<<"bye">>>;<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't always a very clear relationship).<br>
<br>You can also have the Shred report it'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's id number while sporking it;<br>
<<<(spork ~foo()).id()>>>;<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't recommend the /examples/ directory highly enough as a resource.<br>
<br>Yours,<br>Kas.<br><br> </div><br></div><br>