FileDocCategorySizeDatePackage
AbstractSelectionKey.javaAPI DocJava SE 6 API1448Tue Jun 10 00:25:42 BST 2008java.nio.channels.spi

AbstractSelectionKey

public abstract class AbstractSelectionKey extends SelectionKey
Base implementation class for selection keys.

This class tracks the validity of the key and implements cancellation.

author
Mark Reinhold
author
JSR-51 Expert Group
version
1.13, 06/06/07
since
1.4

Fields Summary
private volatile boolean
valid
Constructors Summary
protected AbstractSelectionKey()
Initializes a new instance of this class.

 
Methods Summary
public final voidcancel()
Cancels this key.

If this key has not yet been cancelled then it is added to its selector's cancelled-key set while synchronized on that set.

        // Synchronizing "this" to prevent this key from getting canceled
        // multiple times by different threads, which might cause race
        // condition between selector's select() and channel's close().
        synchronized (this) {
	    if (valid) {
                valid = false;
                ((AbstractSelector)selector()).cancel(this);
	    }
	}
    
voidinvalidate()

					// package-private
	valid = false;
    
public final booleanisValid()


        
	return valid;