harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Zhang" <zhanghuang...@gmail.com>
Subject Re: [Fwd: [classlib][NIO|VMI]Interruptible channel implementation - how to interact with Thread?]
Date Fri, 23 Jun 2006 13:43:59 GMT
Hey Alexander,

Please see my comments inline.

On 6/23/06, Alexander Kleymenov <kleymenov@gmail.com> 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
begin/end should do all these things for subclass. Have a look at the spec
about "end":
AsynchronousCloseException - If the channel was asynchronously closed
ClosedByInterruptException - If the thread blocked in the I/O operation was

> 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: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org

Andrew Zhang
China Software Development Lab, IBM

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message