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
Post a Comment