public void run() {
		while(true) {
			try{
				//process any pending changes
				synchronized(this.changeRequests){
					Iterator changes = this.changeRequests.iterator();
					while(changes.hasNext()){
						ChangeRequest change = (ChangeRequest) changes.next();
						
						switch(change.type){
						case ChangeRequest._CHANGEOPS:
							SelectionKey key = change.socket.keyFor(this.selector);
							key.interestOps(change.ops);
						}
					}
					
					this.changeRequests.clear();
				
				}
				this.selector.select();
				
				Iterator selectedKeys = this.selector.selectedKeys().iterator();
					while(selectedKeys.hasNext()) {
						SelectionKey key = (SelectionKey) selectedKeys.next();
						selectedKeys.remove();
						
							if(!key.isValid()){
								continue;
							}
							if(key.isAcceptable()) {
								this.accept(key);
							}
							else if(key.isReadable()) {
								this.read(key);
							}
							else if(key.isWritable()){
								this.write(key);
							}
						}
			} catch(Exception e){
				e.printStackTrace();
			}
		}
	}