我遇到了一个问题,当条件达到很多次时,如何调用一次方法!例如:调用方法一次
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'。 –