Search Results

Search found 1 results on 1 pages for 'londondreams'.

Page 1/1 | 1 

  • how to serialize function depending on what instance of object calls it, if same instance call in a thread then do serialize else not

    - by LondonDreams
    I have a function which fetches and updates some record from db and I am trying to make sure each if the function is called by same instance of object(same Or different thread) then function should behave synchronized else its a call from different object instance function need not to be synchronized. I have tried it use a lock per client. That is, instead of synchronizing the method directly using explicit locking through lock objects using Map. function is like :- getAndUpdateMyHitCount(myObjId){ //go to db and get unique record by myObjId //fetch value , increment , save update } And this function may get call is same thread by different Or same object instance But as fetching and matching from Map is slow , Is there other optimized way to do this ? Found similar at this Question but dont feel that is optimized

    Read the article

1