Why is ModelFragment.deliverModel() synchronized in CommonsWare 4.7 turorial #12?

54 Views Asked by At

I'm working my way though version 4.7 of the CommonsWare master book. I'm up to tutorial #12. My question relates to the deliverModel() method in ModelFragment. Why is it synchronized?

My confusion comes from my understanding that that method (deliverModel()) should already be only called from the UI thread. It's called from a fragment onActivityCreated() and an AsyncTask onPostExecute().

Thank you, Lee

1

There are 1 best solutions below

1
CommonsWare On BEST ANSWER

Why is it synchronized?

For no good reason, apparently. I am sure that I had a reason once upon a time, but you are correct -- it is only invoked on the main application thread at present. I will remove the synchronized keyword sometime in the future.