I have synchronized static methods in a class called Remote which are invoked from a service to fetch data from the network. The service is an IntentService that's started every time the user scrolls down a list in the UI and more items need to be fetched. The methods are synchronized because they're also called from another source, the syncadapter. Two calls to the same method in Remote can't interleave. But since my syncadapter is running on a separate process making the methods synchronized doesn't enforce thread safety and I was getting inconsistent states.
I solved this by switching the syncadapter back to run in the main process. More specifically removing the android:process
value from the syncservice. But I was wondering if there was a much more robust way of doing, one which works irrespective of the syncadapter's location.