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

Tony Stevenson moved DEFT-102 to AWF-70:
----------------------------------------

    Reporter: Niklas Gustavsson
         Key: AWF-70  (was: DEFT-102)
     Project: Apache AWF  (was: Deft)
    
> Thread safe JMX
> ---------------
>
>                 Key: AWF-70
>                 URL: https://issues.apache.org/jira/browse/AWF-70
>             Project: Apache AWF
>          Issue Type: Bug
>            Reporter: Niklas Gustavsson
>            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.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to