boolean add ( Runnable runnable ) { int spins = 0 ; RunnablePair entries ; while ( ( entries = callbacks . get ( ) ) != END ) { if ( callbacks . compareAndSet ( entries , new RunnablePair ( runnable , entries ) ) ) { return true ; } if ( spins ++ > MAX_SPINS ) { Thread . yield ( ) ; spins = 0 ; } } return false ; }
Attempt to add an event listener to the list of listeners .