LinkTerminated without linked thread?
Stephan
stephan_schiffels at mac.com
Thu Jan 24 02:57:25 PST 2013
Hi,
I am getting totally confused by Exceptions and Multi-threading
with std.concurrency.
I have a simple setup:
- the main thread spawns several child-threads
- each child-thread performs a task
- each child-thread sends their result back to the main
thread and finishes.
- the main thread uses receiveOnly to get the message.
To spawn the child-threads I use spawn, not spawnLinked.
Nevertheless, in all runs, at some point the program finishes
with an uncaught LinkTerminated exception!
I am confused, because I thought, that LinkTerminated can only
happen if the child-threads are started with spawnLinked. In
small test programs, I don't get LinkTerminated exceptions if a
child thread crashes. So my first question is: Where does the
LinkTerminated Exception come from, when the only functions from
std.concurrency that I use are "spawn" and "receiveOnly".
My second question: Given that spawn works as documented and
expected: How can I report an Error or an Exception thrown in a
child-thread? Should I wrap the whole function that is spawned in
a try-catch statement to print any exception manually?
Thanks for any clarification!
Stephan
More information about the Digitalmars-d
mailing list