On Mon, Jul 1, 2013 at 5:08 PM, Senaka Fernando <[email protected]> wrote:

> Hi all,
>
> Is it possible to obtain a scheduled thread pool executor from the
> CarbonContext? I see a few benefits of doing that.
>
> 1. Naming threads on a tenant-basis, making it easier to debug a MT setup.
> 2. Being able to get more control over the thread creation/consumption
> processes in the future.
>

+1.
and We should prevent tenant users (webapps, etc) from accessing this..

thanks,

>
> WDYT?
>
> Thanks,
> Senaka.
>
>
> On Wed, Jun 19, 2013 at 11:52 PM, Nirmal Fernando <[email protected]> wrote:
>
>> +1, this would be very useful.
>>
>> Sent via my mobile
>> -- Nirmal --
>> On Jun 19, 2013 8:55 PM, "Srinath Perera" <[email protected]> wrote:
>>
>>>  We need to name our thread pools, specially in Carbon. There may be
>>> some we cannot name in Tomcat, but what we can, we should. This will save
>>> lot of time when we have to debug thread related issues. (e.g. Thread leak,
>>> with names it is very easy to detect which one is leaking).
>>>
>>> I will create a redmine.
>>>
>>> You can name threads as follows.
>>>
>>> 1) You can pass your own ThreadFactory to ScheduledThreadPoolExecutor.
>>> Your ThreadFactory will create thread and can give it any name you want.
>>> Your ThreadFactory can also reuseExecutors.defaultThreadFactory(), and only
>>> change the name before returning the thread.
>>>
>>> e.g. following will do
>>>
>>>     public class NamedThreadFactory implements ThreadFactory{
>>>
>>>         final ThreadFactory factory = Executors.defaultThreadFactory();
>>>
>>>         AtomicInteger count = new AtomicInteger();
>>>
>>>         @Override
>>>
>>>         public Thread newThread(Runnable r) {
>>>
>>>             Thread thread = factory.newThread(r);
>>>
>>>             thread.setName("MyThreadName-"+count.incrementAndGet());
>>>
>>>             return thread;
>>>
>>>         }
>>>
>>>     }
>>>
>>> 2) If you have Guvava, then you can use ThreadFactoryBuilder
>>>
>>> See
>>> http://stackoverflow.com/questions/5740478/how-to-name-the-threads-of-a-thread-pool-in-java
>>>
>>>
>>> ============================
>>> Srinath Perera, Ph.D.
>>>   Director, Research, WSO2 Inc.
>>>   Visiting Faculty, University of Moratuwa
>>>   Member, Apache Software Foundation
>>>   Research Scientist, Lanka Software Foundation
>>>   Blog: http://srinathsview.blogspot.com/
>>>   Photos: http://www.flickr.com/photos/hemapani/
>>>    Phone: 0772360902
>>>
>>> _______________________________________________
>>> Architecture mailing list
>>> [email protected]
>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>
>>>
>> _______________________________________________
>> Architecture mailing list
>> [email protected]
>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>
>>
>
>
> --
> *Senaka Fernando*
> Member - Integration Technologies Management Committee;
> Technical Lead; WSO2 Inc.; http://wso2.com*
> Member; Apache Software Foundation; http://apache.org
>
> E-mail: senaka AT wso2.com
> **P: +1 408 754 7388; ext: 51736*; *M: +94 77 322 1818
> Linked-In: http://linkedin.com/in/senakafernando
>
> *Lean . Enterprise . Middleware
>
> _______________________________________________
> Architecture mailing list
> [email protected]
> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>
>


-- 
Supun Malinga,

Senior Software Engineer,
WSO2 Inc.
http://wso2.com
http://wso2.org
email - [email protected] <[email protected]>
mobile - 071 56 91 321
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to