Wed Mar 15 05:51:00 GMT 2000
Boehm, Hans wrote,
> Thread A decides it wants to cancel thread B. How can it
> close the file descriptor, which is located in a local
> variable 28 frames down in B's stack? Even if B cooperated,
> and put the file descriptor in some public place, there's no
> obvious place to put it. It can't put it in a fixed global
> place, since C and D might overwrite it.
I don't see this as a problem specific to interruptable IO or
even concurrency. Similar issues might arise in, for example,
(syntactic) error handling/recovery in a recursive descent
parser, or any number of other scenarios where the stack is
used to encode an objects state.
In fact, it looks like a straightforward software design issue
to me. Effectively what you're saying is that cancellation is a
first class aspect of the behaviour associated with thread B.
That being so it should be exposed at the interface level and
then implemented in whatever the appropriate way is. For a
simple example: B's Runnable instance might have a register()
method to allow the 28-frame-down FD to be associated with the
the state of thread B as a whole; and a cancel() method
accessible to A which closes it.
Miles Sabin Cromwell Media
Internet Systems Architect 5/6 Glenthorne Mews
+44 (0)20 8817 4030 London, W6 0LJ, England
More information about the Java