I want to understand Listener mechanism in Java.
My query is regarding the notification, if there are 50 listener then will each notification be sent only and only if first one is complete
for eg
we call receiveBootEvent () on one listener and other listener will be only called when it returns from earlier call.
((BootListener) lCopy.elementAt( lIndex )).receiveBootEvent( aEventType );
-----------code -----------
public interface BootListener {
/** Receives a boot event.
* @param aEventType the type of the event.
*/
public void receiveBootEvent( int aEventType );
}
**********************************************
public void notifyListener( int aEventType ) {
if( aEventType == END_OF_BOOT ) mIsBootDone = true;
// Checks the number of listeners
if( mListener.size() == 0 ) return;
// Makes a local copy
Vector lCopy;
synchronized( this ) {
lCopy = (Vector) mListener.clone();
}
// Notifies all the listeners
for( int lIndex = 0 ; lIndex < lCopy.size() ; lIndex++ ) {
try {
((BootListener) lCopy.elementAt( lIndex )).receiveBootEvent( aEventType );
}
catch( Exception lException ) {
}
}
}
My query is regarding the notification, if there are 50 listener then will each notification be sent only and only if first one is complete
for eg
we call receiveBootEvent () on one listener and other listener will be only called when it returns from earlier call.
((BootListener) lCopy.elementAt( lIndex )).receiveBootEvent( aEventType );
-----------code -----------
public interface BootListener {
/** Receives a boot event.
* @param aEventType the type of the event.
*/
public void receiveBootEvent( int aEventType );
}
**********************************************
public void notifyListener( int aEventType ) {
if( aEventType == END_OF_BOOT ) mIsBootDone = true;
// Checks the number of listeners
if( mListener.size() == 0 ) return;
// Makes a local copy
Vector lCopy;
synchronized( this ) {
lCopy = (Vector) mListener.clone();
}
// Notifies all the listeners
for( int lIndex = 0 ; lIndex < lCopy.size() ; lIndex++ ) {
try {
((BootListener) lCopy.elementAt( lIndex )).receiveBootEvent( aEventType );
}
catch( Exception lException ) {
}
}
}