java - DropWizard API and in memory persistence - race condition -


i creating simple demo system using dropwizard create simple rest api use hashmap , arraylist data persistence.

i wondering multiple requests coming in , there being race conditions read/write data.

is simple enough synchronise access these methods? alleviate potential issues?

this demo job interview there won't major load on api. want address potential issues , i'm wondering if synchronised methods trick? thanks.

race conditions solved locking objects used different threads/processes.

you use collections.synchronizedmap() , collections.synchronizedlist() synchronized instances, might not suitable if complete state consists of multiple objects.

in case should guard full state synchronizing access it. use unsynchronized versions of collection instances, synchronize access object handles state.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -