+1 Yes we need to do this.
On Sun, May 11, 2014 at 7:26 AM, Nirmal Fernando <nirmal070...@gmail.com>wrote: > Hi Udara, > > This was discussed several times in the list past and yes we should use > executors. +1 for fixing it. > > > On Sat, May 10, 2014 at 7:36 PM, Udara Liyanage <ud...@wso2.com> wrote: > >> Hi Devs, >> >> Code snippets similar to below can be seen in some places where threads >> wait till "terminated" variable becomes true . The variable is set to true, >> when the component is deactivated. IMO this is bit hard to maintain. >> >> // Keep the thread live until terminated >> while (!terminated) { >> try { >> Thread.sleep(1000); >> } catch (InterruptedException ignore) { >> } >> } >> if (log.isInfoEnabled()) { >> log.info("Autoscaler topology receiver thread terminated"); >> } >> >> protected void deactivate(ComponentContext context) { >> asTopologyReceiver.terminate(); >> autoscalerHealthStatEventReceiver.terminate(); >> } >> >> How about adding a thread executor as [1] to what threads are added at >> creation time and executor is shutdown when component is deactivated. >> >> [1] >> http://www.vogella.com/tutorials/JavaConcurrency/article.html#threadpools >> -- >> >> Udara Liyanage >> Software Engineer >> WSO2, Inc.: http://wso2.com >> lean. enterprise. middleware >> >> web: http://udaraliyanage.wordpress.com >> phone: +94 71 443 6897 >> > > > > -- > Best Regards, > Nirmal > > Nirmal Fernando. > PPMC Member & Committer of Apache Stratos, > Senior Software Engineer, WSO2 Inc. > > Blog: http://nirmalfdo.blogspot.com/ > -- Imesh Gunaratne Technical Lead, WSO2 Committer & PPMC Member, Apache Stratos