Post a Job  |   Ask a Question?   |   Already registered? login or register
krishna kumar
23/01/2016 03:36 PM

Doubt in collections?


How to create ThreadSafe Cache with out using Synchronized Collection. (without maintains ThreadLocale())
Spam    3 Comments

Basanta,Hota
23/01/2016 15:52:57
I m nt sure. If you don't want to use synchronized collection then use Non synchronized collection nd make them as synchronised by using Collections class utility method like Map m=new HashMap ( ); Collections.synchronizedMap (m); But it also seems like fst one so. If anyother approach is there plz reply bro

samir,panda
23/01/2016 20:02:22
better to use concurrentHashMap ---------------------------------------- the reason behind is its allows the concurrent read and thread-safe operation .. during update operation its lock only one segment not the whole map.. if some update operation going on some block at the same time you still able to read it in concurrentHashMap and you look for read-operation only in cache

Basanta,Hota
23/01/2016 20:29:14
Samir bro ur answer is crt.but ConcurentHashMap is synchronized but he strictly mention in question they don't want to use synchronized collection So as per my view. Just declare all sharable data as local to that perticular method otherwise take it as argument to that method. If data is non sharable then it's not possible U should have to use synchronized collection like ConcurentHashMap as Samir bro already explain the advantages of it

Languages :
xml