我遇到了一個問題,當條件達到很多次時,如何調用一次方法!例如:調用方法一次
public void onLocaitonChanged(Location location){
// this if statement may achieve the condition many times
if(somethingHappened){
callAMethodOnce();// this method is called once even if the condition achieved again
}
}
請與
考慮一下,如果多線程使用'AtomicBoolean'。 –