android - Java Array list synchronization if written in one thread and read in another -


i have controller class runs in thread , composes local variable list this

thread a

list = new arraylist<map<string, order>>(); list.add(...); list.add(...); 

where order java bean several primitive properties string, int, long, etc.

once list constructed, reference passed ui thread (thread b) of activity , accessed there. cross-thread communication done using handler class + post() method.

so question is, can access list data thread b without synchronization @ all? please note, after constructed in thread a, list not accessed/modified @ all. exists local variable , passed thread b afterwards.

it not clear context provide happen:

list = new arraylist<map<string, order>>(); list.add(...); list.add(...); 

if in constructor and list final and this reference not leak constructor and absolutely sure list won't change (for example using unmodifiablelist decorator method) and references order instances not accessible elsewhere may ok not use synchronization. otherwise have sword of damocles on head.

i mentioned order references because may not exceptions if change them somewhere else may lead data inconsistency/corruption.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -