harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: [Fwd: [classlib][NIO|VMI]Interruptible channel implementation - how to interact with Thread?]
Date Wed, 14 Jun 2006 15:12:22 GMT
Geir Magnusson Jr wrote:
> Given that you are blocked, why is it in an unknown state?

The problem is that you typically don't know whether the thread is
actually blocked or not.  So if it is really blocked then, yes,
interrupting it may leave the channel safe for future operations, but if
it were blocked and then you interrupted it just after it awoke and was
reading/writing data then who knows what state you have left the OS in.

Since different OS'es behave differently to interrupting IO operations
in-flight then saying the channel is invalidated by interruptions is the
safe option.

(Note that if you interrupt a thread that is nowhere near a channel
operation the thread will be marked as interrupted, and if it should go
on to attempt a Channel operation then it causes the channel to be
closed! D'oh!)

> Doesn't the channel know that it didn't complete what
> it was trying to do?

Yep, it gets the exception thrown that shows things were interrupted.



Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

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

View raw message