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 Thu, 15 Jun 2006 03:01:42 GMT
On 6/14/06, Magnusson, Geir <geir.magnusson@intel.com> wrote:
>
>
> This font is getting out of hand...
>
> > -----Original Message-----
> > From: Tim Ellison [mailto:t.p.ellison@gmail.com]
> > Sent: Wednesday, June 14, 2006 11:12 AM
> > To: harmony-dev@incubator.apache.org
> > Subject: Re: [Fwd: [classlib][NIO|VMI]Interruptible channel
> > implementation - how to interact with Thread?]
> >
> > 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!)
>
> I realize you may not be able to answer this... This is really just
> interesting learning for me as I've never used NIO in anger...
>
> Given that NIO is an advanced API, why would the NIO EG let the channel
> user simply decide?  If you were interrupted while blocked on the
> channel, you must close.  If not, you can use it...


Most of users may prefer to decide the operation by themselves, but spec
says:
"If this thread is blocked in an I/O operation upon an interruptible channel
then the channel will be closed, the thread's interrupt status will be set,
and the thread will receive a ClosedByInterruptException. " :( It seems we
have no choice.

Geir
>
>
> >
> > > 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.
> >
> > Regards,
> > Tim
> >
> > --
> >
> > 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
> >
>
> ---------------------------------------------------------------------
> 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

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