Hey Alexander,

Please see my comments inline.


On 6/23/06, Alexander Kleymenov <[EMAIL PROTECTED]> wrote:

Hello,

I analyzed this thread and could not find why Archie's suggestion #3
was rejected.
Why we should invent interrupt notification mechanism while Thread has
method interrupted() ?.
This method is from public API, and some interruptable operation can
call it to get know if blocked thread was interrupted or not. And if
the thread was interrupted, this operation acts as specified:
"...and the thread will receive a ClosedByInterruptException"

> Andrew Zhang wrote
> Oh... Got it, thanks, Archie.
> One more question: Where does these code locate? In begin/end method or
main
> body between begin/end?

This code should be located in blocking operation (read() for example)


If I'm writing a InterruptibleChannel which extends from
AbstractInterruptibleChannel, I'll not write such code in my blocking
operation, because spec says :
"A concrete channel class must invoke the begin and end methods before and
after, respectively, invoking an I/O operation that might block
indefinitely."
begin/end should do all these things for subclass. Have a look at the spec
about "end":
"Throws:
AsynchronousCloseException - If the channel was asynchronously closed
ClosedByInterruptException - If the thread blocked in the I/O operation was
interrupted."


Not only Selector, SocketChannel, ServerSocketChannel but also any class
who
> extends AbstractInterruptibleChannel are interruptible channel. Any
> interruptible channel could use begin/end to mark a blocking I/O
operation.

I doubt that just calling of this methods will made blocking
operations interruptable. I.e. we should have interruption support in
[interruptable] blocking operation anyway.


I think yes:) It's enough. I agree with Paulex's proposal. It works because
threadA will make the blocking thread interrupted by running the set action.
Typical action maybe looks like wakeup() or close(), which makes blocking
I/0 exception returns siliently or with error code.

In the case of implementation of setInterruptAction (as Paulex
proposed) we can fall into the problems with managing of such actions
(multiple consequent begin()s could be an example).


Sorry if I missed something.


Any better solution is highly appreicated, Thanks!

Thank You,
Alexander

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Andrew Zhang
China Software Development Lab, IBM

Reply via email to