+1

We have done this in some products like ESB in the past. But this needs to
be a platform wide practice.



On Wed, Jun 19, 2013 at 8:54 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
>
>


-- 

Thanks,
Samisa...

Samisa Abeysinghe
VP Engineering
WSO2 Inc.
http://wso2.com
http://wso2.org
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to