public void run() {
	try {
	    // start read server
	    Selector selector = Selector.open();
	    ServerSocketChannel server_channel = ServerSocketChannel.open();
	    server_channel.configureBlocking(false);
	    server_channel.socket().bind(new InetSocketAddress("localhost", read_port));
	    server_channel.register(selector, SelectionKey.OP_ACCEPT);
	    /*
	     * In order to not having to make many changes in the code it starts by sending
	     * the mutex if it has it.
	     */
	    if (temp_owner) {
		sendMutex();
	    }
	    while (run) {
		selector.select();
		Iterator<SelectionKey> keys = selector.selectedKeys().iterator();
		while (keys.hasNext() && run) {
		    SelectionKey key = (SelectionKey) keys.next();
		    keys.remove();
		    if (!key.isValid()) {
			continue;
		    }
		    /*
		     * If someone connects it gave the mutex. 
		     * Having waiters the server keeps the mutex.
		     * Not having waiters sends the mutex to the next peer.
		     */
		    if (key.isAcceptable()) {
			SocketChannel s = server_channel.accept();
			s.configureBlocking(false);
//			server_channel.register(selector, SelectionKey.OP_READ);
			IT.log("Mutex received...");
			if (lock.hasWaiters()) {
			    IT.log("Holding mutex..");
			    lock.giveMutexToHandler();
			} else {
			    sendMutex();
			}						
		    } else if (key.isReadable()) {
			// read the number of bytes
			SocketChannel channel = (SocketChannel) key.channel();
			ByteBuffer buffer = ByteBuffer.allocate(1000);
			channel.read(buffer);
		    }
		}
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }