I'd recommend a short-term solution using both - first try to join() with a
timeout so that if it's not simply sleeping, it'll give the thread a chance
to complete whatever it's doing, and finally, after the timeout, issuing the
interrupt() since you can more safely assume that the thread is in a sleep
state...
The better (but more involved) solution would require the ability to monitor
the 'state' of the ActiveMonitor so that you can tell if it's sleeping or
actually doing something - but you have to implement it carefully to avoid
race conditions.
Chad
----- Original Message -----
From: "Marcus Crafter" <[EMAIL PROTECTED]>
To: "Avalon Mailing List" <[EMAIL PROTECTED]>
Sent: Friday, September 27, 2002 7:22 AM
Subject: Decomissioning ActiveMonitor issue
> Hi Troops,
>
> Hope all is well.
>
> I've been looking at an issue in ActiveMonitor today, where during
> disposal of the component the current thread blocks till the monitor
> thread dies (ActiveMonitor.stop()).
>
> This causes problems in our environment because our monitor interval
> is set to 30 mins, which means ActiveMonitor.stop() could take up
> to 30 mins to complete due to the current thread waiting for the
> monitor thread to complete.
>
> I changed the code to do an interrupt() instead of a join(), ie. to
> interrupt the monitor thread out of it's sleep(), and everything worked
> fine. The actual diff is below.
>
> Just wondering if there are any issues or problems with this change
> that I'm not aware of ? If so, any ideas how to fix the original
> problem ?
>
> Cheers,
>
> Marcus
>
> Index:
src/java/org/apache/avalon/excalibur/monitor/impl/ActiveMonitor.java
> ===================================================================
> RCS file:
/home/cvs/jakarta-avalon-excalibur/monitor/src/java/org/apache/avalon/excali
bur/monitor/impl/ActiveMonitor.java,v
> retrieving revision 1.3
> diff -u -r1.3 ActiveMonitor.java
> --- src/java/org/apache/avalon/excalibur/monitor/impl/ActiveMonitor.java 8
Sep 2002 00:02:45 -0000 1.3
> +++ src/java/org/apache/avalon/excalibur/monitor/impl/ActiveMonitor.java
27 Sep 2002 13:15:14 -0000
> @@ -80,7 +80,7 @@
> throws Exception
> {
> m_keepRunning = false;
> - m_monitorThread.join();
> + m_monitorThread.interrupt();
> }
>
> public final void run()
>
>
> --
> .....
> ,,$$$$$$$$$, Marcus Crafter
> ;$' '$$$$: Computer Systems Engineer
> $: $$$$: ManageSoft GmbH
> $ o_)$$$: 82-84 Mainzer Landstrasse
> ;$, _/\ &&:' 60327 Frankfurt Germany
> ' /( &&&
> \_&&&&'
> &&&&.
> &&&&&&&:
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>