There isn't an easy way to do it that I could find.  The NioSocketAcceptor 
creates an NioProcessor instance which defers to itssuperclass 
AbstractPollingIoProcessor for its nextThreadName method to determine the name 
of the threads.  I was going to suggest subclassing NioProcessor and having the 
NioSocketAcceptor utilize your class (which just implements nextThreadName), 
but it appears someone decided NioProcessor should be a final class.

The nextThreadName method of the AbstractPollingIoProcessor just names the 
thread based on the class, hence the NioProcessor-#.  In the constructor of 
NioSocketAcceptor, one option is to pass in an instance of an IoAcceptor.  So, 
you might think you could instantiate an NioProcessor, passing an executor that 
is using a custom implemented ThreadFactory that names threads for you...nope!  
When the AbstractPollingIoProcessor starts the threads, it renames them, losing 
whatever your ThreadFactory might've initialized them as.

So, maybe someone else sees some options, but since the NioProcessor class is 
final, it makes it difficult to have a clean solution, without having to 
duplicate code or modify the mina source.

---

If you're looking to rename the threads for the ExecutorFilter, that goes 
pretty smoothly.  Just pass in an OrderedThreadPoolExecutor with a 
ThreadFactory specified that allows for naming of the threads on creation.

Aaron Simmons wrote:
>Is it possible to override mina's default thread naming?  It defaults to 
>NioProcessor-1, NioProcessor-2, etc.  I'd like to have it be MyCustomString-1, 
>MyCustomString-2, etc.


      

Reply via email to