You shouldn’t change the list of
components that you persist/update while another thread is working on it.
The thread that persists/updates entities must own the entity objects i.e. no other thread may interfere with the state while the transaction is running. You can only make use of the objects again after the transaction finished.
I don’t know what your application does, but if you need access to the objects in your main thread you could copy the objects for the flush operation. This way, the thread doing the flush will properly own the objects and can safely work on them.
CLICK HERE to find out more related problems solutions.