onReceive()
线程方法是安全的BroadcastReceiver
还是我需要自己实现同步?
如果我有任何在方法内部使用的类级别变量onReceive()
,并且该onReceive()
方法被快速调用多次,它会导致问题吗?
public class MyBroadCastReceiver extends BroadcastReceiver {
boolean isFirstTrigger = true;
@Override
public void onReceive(Context context, Intent arg1) {
if(isFirstTrigger)
{
//Do something time consuming
isFirstTrigger = false;
}
}