public void run() {
		try {
			while (true) {
				int n = selector.select();
				if (n == 0) {
					continue;
				}
				Iterator<SelectionKey> iter = selector.selectedKeys()
						.iterator();

				while (iter.hasNext()) {
					SelectionKey key = iter.next();

					if (!key.isValid()) {
						continue;
					} else if (key.isAcceptable()) {
						acceptOperation(key);
					} else if (key.isReadable()) {
						readOperation(key);
					} else if (key.isWritable()) {
						//TODO
					}
					iter.remove();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			handler.execptionCaught(session, e);
		}
	}