private void waitForRegister(final RegisterableChannelImpl s, final int validOps, final Object listener, boolean needWait) 
					throws IOException, InterruptedException {
		if(s.isBlocking()) 
			throw new IllegalArgumentException(s+"Only non-blocking selectable channels can be used.  " +
					"please call SelectableChannel.configureBlocking before passing in the channel");

		//in SelectorImpl.java(check sun's SCSL code), SelectorImpl grabs
		//a lock in select() method.  This register tries to grab the same
		//lock, so we need to wakeup the select method here and have it do
		//the processing of this request so it can release the lock so
		//the register can grab the lock.
		SelectorRunnable r = new SelectorRunnable() {
			public void run() throws ClosedChannelException {
                try {
                    registerChannelOnThisThread(s, validOps, listener);
                } catch (Exception e) {
                    throw new RuntimeException(s+"Exception", e);
                }
			}
			public String toString() {
				return Helper.opType(validOps);
			}
		};
		ChannelRegistrationListener regRequest = selector.createRegistrationListener(s, r, this);
		
		listenerList.add(ChannelRegistrationListener.class, regRequest);
		
		regRequest.waitForFinish(needWait);
	}