java - Singleton updates in a Multithreaded environment -


in multithreaded environment have singleton static arraylist.

let's 1 thread gets instance , doing "for" loop arraylist. reading. no updates. might take sometime complete. while happens, thread updates arraylist.

what happen loop (first thread)? ideally "for" loop complete "old" data , if instance again, new set of data.

is trick in case not use volatile ? or create new arraylist static arraylist "for" loop? or... ?

it looks using copyonwritearraylist might way go though costly on memory

http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/copyonwritearraylist.html


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -