How to change Mina NioProcessor thread names

1k views Asked by At

I want to change mina NioProcessor thread names because when I print thread names using log4j, they aren't very meaningful to me (e.g. NioProcessor-36, NioProcessor-42) especially when there are multiple Processors around. Is it possible?

1

There are 1 answers

0
Ricardo Cristian Ramirez On BEST ANSWER

Below solution offers custom thread names after NioProcessor threads.

  1. Create a custom thread factory which gives your desired names to new threads. Here is an example how to do this.
  2. Create an executor filter like below

    Executor executor = Executors.newFixedThreadPool(1, new YourThreadFactory("namingConvention"))
    acceptor.getFilterChain().addFirst("executor", executor)
    

If you already have an executor filter, then you will just give a thread factory as parameter.