I have certain values in a arry. Now while trying to apply multi threading i have to update array. Should I divide the arry to multiple sub array or could write safely to array. for example thrad 1 would write to arr and thread 2 would write to arr?
You could put the code that accesses the array in a synchronized block or method. Alternative is to used some synchronized collection, souch as CopyOnWriteArrayList. I would preffer a synchronized block.
Thanks martin..My intention is that since the updataion would be index wise and there would be overlap of data, hence data inconsistency is not there.Only doubt I have whether it would throw any exception.
I am not sure whether data overriding by multiple threads over a specific index is alright for you or not but as far as exceptions are concerned there will not be any if we are not going beyong he size of the array.