[ 
https://issues.apache.org/jira/browse/DEFT-102?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Roger Schildmeijer resolved DEFT-102.
-------------------------------------

    Resolution: Fixed

> Thread safe JMX
> ---------------
>
>                 Key: DEFT-102
>                 URL: https://issues.apache.org/jira/browse/DEFT-102
>             Project: Deft
>          Issue Type: Bug
>            Priority: Minor
>
> The current JMX usage is not thread safe. (The "jmx thread" is accessing 
> methods on e.g IOLoop.)
> One way to solve this is to use IOLoop.addCallback and explicit locking.
> e.g (semi pseudo, missing some try catch etc)
>     @Override
>       public int getNumberOfRegisteredIOHandlers() {
>               //return handlers.size();
>               final Object lock = new Object(); // maybe a ReentrantLock is 
> more appropriate
>               final int[] rv = new int[1];
>               IOLoop.INSTANCE.addCallback(new AsyncCallback() { 
>                       @Override
>                       public void onCallback() {
>                           rv[0] = handlers.size();
>                           lock.notifyAll();
>                       }
>               }
>               );
>               synchronized (lock) {
>                   lock.wait();
>               }
>               return rv[0];
>       }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to