Dear all,
Sorry if I missed some section in the Oz documentation concerning
this issue.
How can I catch an exception raised in a (possibly nested) thread?
Please consider the dummy example below, which is simply an edited
version of an exception example in the tutorial. The difference is
solely that Eval raises an exception from within a thread. As a
consequence, it appears that the catch statement does never see this
exception -- it is instead reported by the top-level.
proc {Eval E}
thread
case E
of plus(X Y) then {Browse X+Y}
[] times(X Y) then {Browse X*Y}
else raise illFormedExpression(E) end
end
end
end
try
{ForAll [plus(5 10) times(6 11) min(7 10)] Eval}
catch
illFormedExpression(X) then {Browse '** '#X#' **'}
end
As I said, this is only a dummy example. What I actually want to do
is terminating a number of threads after one of them found a result,
and I though that raising an exception containing the result would be
a clean technique. BTW: I also tried terminating all my threads
explicitly (see code below). Yet this resulted in another exception
-- namely kernel(deadThread ...) ...) -- and so I was looking for
alternative solutions..
{ForAll MyThreads Thread.terminate}
Thank you!
Best
Torsten
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users