Search code examples
androidlistviewthread-safetyandroid-listviewlistadapter

Will it hurt performance to make ListAdapter.getView() synchronized?


In my code I've found that for performance reasons to prevent repeated and slow dependent object instantiations, it would be tremendously helpful to assume that the calls to ArrayAdapter.getView() are not executed concurrently by marking it synchronized.

Is there any reason to believe that Android issues multi-threaded calls to getView and that applying the synchronized keyword will hurt performance?


Solution

  • getView() will only be called on the main application thread, unless for some bizarre reason you call it yourself on a background thread. Hence, synchronization is unnecessary and will add overhead.