Reading up on the RecordStore documentation, one can read the following:
Record store implementations ensure that all individual record store operations are atomic, synchronous, and serialized, so no corruption will occur with multiple accesses.
and then at the very next sentence:
However, if a MIDlet uses multiple threads to access a record store, it is the MIDlet's responsibility to coordinate this access or unintended consequences may result.
I'm not sure what to make of this. The operations are atomic and synchronous but I have to synchronize access myself? Assuming I wouldn't need to iterate on the records, what type of synchronization do I need to have for simple add/update/delete functions?
And in case I do need iteration, if I use a RecordEnumeration
, does the enumerateRecords
method take a snapshot of the RecordStore
, or is it directly connected to it?
What I think this means is that two threads simultaneously reading and writing records in a store will likely produce undesirable results; particularly when you rely on a store being in a particular order, or for the records to have known indexes.
Your second question is answered in the Javadoc for
RecordStore.enumerateRecords()
: