Solved the typical NIO channel.register(..) problem, that causes a
deadlock if you want to add a channel to a selector, and the selector is
maintained by another thread. The solution is to introduce a queue and
let the maintainer thread do the registration by waking it up.