You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@excalibur.apache.org by "Kazimierz Pogoda (JIRA)" <de...@excalibur.apache.org> on 2005/07/11 16:48:10 UTC

[jira] Commented: (EXLBR-26) org.apache.avalon.excalibur.monitor.impl.ActiveMonitor is not thread safe

    [ http://issues.apache.org/jira/browse/EXLBR-26?page=comments#action_12315487 ] 

Kazimierz Pogoda commented on EXLBR-26:
---------------------------------------

This code should illustrate the problem:

import org.apache.avalon.excalibur.monitor.FileResource;
import org.apache.avalon.excalibur.monitor.Resource;
import org.apache.avalon.excalibur.monitor.impl.ActiveMonitor;

public class ActiveMonitorTest {

    public static void main(String[] args) throws Exception {
        final ActiveMonitor monitor = new ActiveMonitor();
        monitor.setFrequency(1);
        monitor.start();
        for (int i = 0; i < 10; i++) {
            final Resource resource = new FileResource("/tmp");
            final Thread thread = new Thread() {
                public void run() {
                    while (true) {
                        monitor.addResource(resource);
                        monitor.removeResource(resource);
                    }
                }
            };
            thread.start();
        }
    }

}


> org.apache.avalon.excalibur.monitor.impl.ActiveMonitor is not thread safe
> -------------------------------------------------------------------------
>
>          Key: EXLBR-26
>          URL: http://issues.apache.org/jira/browse/EXLBR-26
>      Project: Excalibur Components
>         Type: Bug
>   Components: Monitor
>     Versions: 1.0.2
>  Environment: Linux 2.6.11 + jdk5.0
>     Reporter: Kazimierz Pogoda

>
> getResources() method of the AbstractMonitor should be probably synchronized on m_resources like the other methods in this class.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org