AsFirebaseMessagingService
does not use the Main Thread
, I am just wondering as all my code in all of my activities or fragments run in UI thread(Main Thread
). Now suppose my activity's onCreate
method is executing and then I receive the push notification
. Will these two blocks of code run in parallel, or will the push notification code wait in the queue until onCreate()
method OR Activity's last life cycle method gets executed?
Edit- As you are saying code will run parallelly then suppose I have a variable in App.java
public class App extends Application {
int ctr = 100;
}
StatusActivity.java
public class StatusActivity extends BaseActivity {
public void onCreate() {
fun();
}
public void fun() {
int d = App.ctr - 1;//Step 1 Here d = 99
int m = App.ctr - 1; // Step 3 Here m = 98
}
}
FcmListener.java
public class FcmListener extends FirebaseMessagingService {
Override
public void onMessageReceived(RemoteMessage mssg) {
App.ctr = App.ctr - 1;//STEP 2 // Now App.ctr = 99
}
}
Now as you can see in the above code there will be problems if push notif code executes in parallel with fun()
. I want push_notif
and fun()
to run serially, where order doesn't matter but not in parallel.