Naming of netty worker threads

One of the slightly annoying quirks in Netty is the fact that OIO worker names are not meaningful.

Here is some sample code to fix this:

/* give worker threads a meaningful name such as "OIO-worker-2" */
try {
    ThreadRenamingRunnable.setThreadNameDeterminer(
        new ThreadNameDeterminer() {
            public String determineThreadName(String currentThreadName,
                                                String proposedThreadName) throws Exception {
          
                StringBuffer sb = new StringBuffer(WORKER_THREADNAME_PREFIX);
                sb.append(currentThreadName.substring(currentThreadName.lastIndexOf('-')));
                return sb.toString();
            }
        });         
} catch (Exception e) {
         
    /* fall back to default thread name, e.g. pool-X-thread-X */
    ThreadRenamingRunnable.setThreadNameDeterminer(ThreadNameDeterminer.CURRENT);
}