Closed yccheok closed 6 years ago
Hi @yccheok! The intention of having the synchronized in this method is to avoid items being added to the map while the copy is being made. Do you think the responsibility of locking it should be of the user of lib?
Hi @luizgrp
Yes. All the time, my view on this library is that, it shouldn't have any knowledge on threading. Hence, seeing synchronized
keyword in the code, seem a bit awkward to me :)
I believe you had achieve goal of SectionedRecyclerViewAdapter
- provides section liked UI effect for RecyclerView. For threading issues, it should be the responsible of another library, or another class, or responsible of developers themselves.
Cool, I agree with you on this, will change it!
https://github.com/luizgrp/SectionedRecyclerViewAdapter/blob/1f248435ea09561c42afabf492adb427e2ab626e/library/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/SectionedRecyclerViewAdapter.java#L519
Is
synchronized (sections) {
required, as it seems like unable to preventjava.util.ConcurrentModificationException
, if user is callinggetCopyOfSectionsMap
from a non-UI thread.I don't think it is a bad thing, if such exception is being thrown if user is calling
getCopyOfSectionsMap
from a non-UI thread.