avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Steuck <greg-avalon-...@nest.cx>
Subject Decomissioning ActiveMonitor issue
Date Fri, 27 Sep 2002 17:19:10 GMT
Hi Marcus,

>>>>> "Marcus" == Marcus Crafter <crafterm@fztig938.bank.dresdner.net>
    Marcus> 	This causes problems in our environment because our
    Marcus> monitor interval is set to 30 mins, which means
    Marcus> ActiveMonitor.stop() could take up to 30 mins to complete
    Marcus> due to the current thread waiting for the monitor thread
    Marcus> to complete.
    Marcus> 	I changed the code to do an interrupt() instead of a
    Marcus> join(), ie. to interrupt the monitor thread out of it's
    Marcus> sleep(), and everything worked fine. The actual diff is
    Marcus> below.

But it shouldn't work fine. InterruptedException is simply ignored by
delay() in the monitor thread and it resumes waiting. Could you double
check that your fix actually works? If it does, could you explain how?

    Marcus> 	Just wondering if there are any issues or problems
    Marcus> with this change that I'm not aware of ? If so, any ideas
    Marcus> how to fix the original problem ?

Could somebody explain why InterruptedException is suppressed in
delay() and sleep is resumed by run()? It seems to be wrong: it's
not like somebody is running around sending InterruptedException
exceptions to thread and you need to ignore them. The only thing
that can send such exception to the monitor thread is the
ActiveMonitor that created it in the first place. And that exception
shouldn't be ignored.

So, the patch I'm attaching:

1) interrupts the thread
2) waits for it to terminate (Hi Chad!)
3) terminates the monitor thread on InterruptedException
4) declares m_keepRunning volatile since it is accessed concurrently,
   even though it is a 4 byte entity and assignment is supposed
   to be atomic

The right way to handle this m_keepRunning thing would be to use a
Latch (e.g. from Doug Lea's util.concurrent). Any plans to integrate
or just use util.concurrent?


View raw message