diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java
index <HASH>..<HASH> 100644
--- a/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java
+++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java
@@ -89,11 +89,14 @@ class NioWorker implements Runnable {
         boolean firstChannel = started.compareAndSet(false, true);
         Selector selector;
         if (firstChannel) {
+            selectorGuard.writeLock().lock();
             try {
                 this.selector = selector = Selector.open();
             } catch (IOException e) {
                 throw new ChannelException(
                         "Failed to create a selector.", e);
+            } finally {
+                selectorGuard.writeLock().unlock();
             }
         } else {
             selector = this.selector;
Potential fix for NPE during SocketChannel.register(..)