What data structure should I use in Java multithreading? -
there new project planning start in few days , review done on design points.
there old legacy code uses hashtable in memory database. there 1 thread consumes xml feed files , sockets , populates hashtable , thread validation , update , third thread persists validated data in database if validation successful.
as performance struggling during update (meaning other 2 threads catching fast , waiting validation thread complete), planning use concurrenthashmap prototype solution , create more 1 thread validation. still in prototyping stage feedback on if going in right direction. thank in advance.
i don't think concurrent hash map going help. assume create number of entries in hash table , upon validation, store them in database. problem persistence thread has wait validation complete.
if entries in hash table interrelated , validator must check of them - there not can wait.
however, if can break down validation in smaller chunks (easiest case if entries not related @ all), either parallelize validation multiple threads or use consumer/producer pattern store data. is, once validator completes chunk, posts queue , persistence thread reads queue , store chunk.
still if entries must checked, can persist them in chunks rollback if validation fails.
Comments
Post a Comment