Before I ask anything you might tell me to read docs. But I am still a beginner and I am not handling docs so easily. My question is does iterator in SynchronizedList
block 'entire iteration process (loop)' or just its methods?
Meaning: Can another thread do some work on synchronizedList
instance while iteration is 'going on'? Or it can do some work after thread that called next()
, as I noticed next()
is also synchronized.
I would appreciate any help, thanks :)
Just its methods.
There is no way for the class to detect if it is being used in a loop.
If you need the list to be synchronised for the entirety of a loop, externally synchronize on the list: