You're right Doug, I ran a simple test to verify that interrupt() will
result in a InterruptedException on a call to sleep(), so my hang up
problem is something else.  I'm going to rerun my job and post a
thread dump of the hang up.

Calvin


On 6/1/07, Doug Cutting <[EMAIL PROTECTED]> wrote:
Calvin Yu wrote:
> The problem seems to be with the MapTask's (MapTask.java) sort
> progress thread (line #196) not stopping after the sort is completed,
> and hence the call to join() (line# 190) never returns.  This is
> because that thread is only catching the InterruptedException, and not
> checking the thread's interrupted flag as well.  According to the
> Javadocs, an InterruptedException is thrown only if the Thread is in
> the middle of the sleep(), wait(), join(), etc. calls, and during
> normal operations only the interrupted flag is set.

I think that, if a thread is interrupted, and its interrupt flag is set,
and sleep() is called, then sleep() should immediately throw an
InterruptedException.  That's what the javadoc implies to me:

   Throws: InterruptedException - if another thread has interrupted
   the current thread.

So this could be a JVM bug, or perhaps that's not the contract.

I think we should fix this as a part of HADOOP-1431.  We should change
that to use the mechanism we use elsewhere.  We should have a 'running'
flag that's checked in the thread's main loop, and method to stop the
thread that sets this flag to false and interrupts it.  That works
reliably in many places.

Perhaps for the 0.14 release this logic should be abstracted into a base
class for Daemon threads, so that we don't re-invent it everywhere.

Doug

Reply via email to