public synchronized void cancelAll ( ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( tc , "cancelAll" , this ) ; //flag that we are cancelling all of the existing alarms _cancelAll = true ; //variables to hold copies of the lists of existing alarms LinkedList oldPendingList = null ; LinkedList oldFiredList = null ; synchronized ( _firedAlarmsLock ) { synchronized ( _pendingAlarmsLock ) { //no need to suspend the alarm thread because after this the two lists will be empty //take a copy of the two lists and create new empty lists in their place oldPendingList = _pendingAlarms ; _pendingAlarms = new LinkedList ( ) ; oldFiredList = _firedAlarms ; _firedAlarms = new LinkedList ( ) ; //reset the next target alarm time _nextAlarm = MPAlarmThread . SUSPEND ; //flag that all of the alarms have been canceled //(we haven't actually canceled them yet but they are not in the //active lists) _cancelAll = false ; } } //release the locks for the two lists so that new alarms can be started //while we are still cleaning up the old ones //iterate over the first list MPAlarmImpl alarm = ( MPAlarmImpl ) oldPendingList . getFirst ( ) ; while ( alarm != null ) { MPAlarmImpl next = alarm . next ( ) ; //cancel each alarm alarm . cancel ( ) ; //remove it from the list oldPendingList . remove ( alarm ) ; //return the alarm object to the object pool _alarmPool . add ( alarm ) ; alarm = next ; } //iterate over the second list alarm = ( MPAlarmImpl ) oldFiredList . getFirst ( ) ; while ( alarm != null ) { MPAlarmImpl next = alarm . next ( ) ; // cancel each alarm alarm . cancel ( ) ; // remove it from the list oldFiredList . remove ( alarm ) ; // return the alarm object to the object pool _alarmPool . add ( alarm ) ; alarm = next ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( tc , "cancelAll" ) ; }
cancel all of the alarms which are currenly registered .