Search code examples
apache-minamina

How to change Mina NioProcessor thread names


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?


Solution

  • 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.