mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
StateMachine listeners are now more thread safe :-)
git-svn-id: https://ipscan.svn.sourceforge.net/svnroot/ipscan/trunk@333 375186e5-ef17-0410-b0b6-91563547dcda
This commit is contained in:
parent
a21339dc8a
commit
4170a23287
@ -6,6 +6,7 @@
|
||||
package net.azib.ipscan.core.state;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -18,7 +19,7 @@ public class StateMachine {
|
||||
|
||||
private ScanningState state = ScanningState.IDLE;
|
||||
|
||||
private List<StateTransitionListener> transitionListeners = new ArrayList<StateTransitionListener>();
|
||||
private List<StateTransitionListener> transitionListeners = Collections.synchronizedList(new ArrayList<StateTransitionListener>());
|
||||
|
||||
/**
|
||||
* @param state
|
||||
@ -64,8 +65,10 @@ public class StateMachine {
|
||||
}
|
||||
|
||||
private void notifyAboutTransition() {
|
||||
for (StateTransitionListener listener : transitionListeners) {
|
||||
listener.transitionTo(state);
|
||||
synchronized (transitionListeners) {
|
||||
for (StateTransitionListener listener : transitionListeners) {
|
||||
listener.transitionTo(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user