Hi All
I am not an expert in threading but maybe one of you experts can help. My assignment involves using cookies to unlock and lock a record I have being looking through the various threads and this is what i am intending to do.
I create a synchronized hashmap which uses the record number for a key and object that contains the cookie used to lock a record and the record number.
Within my lock method I check the hashmap to see if it contains an object for a particular record number. IF it does I retrieve this object and then lock on this object using a synchronized block.
For example within the method:
In my unlock method I would then remove the object from the
hasmap and call notify all
From my understanding using a synchronized hashmap means that only one
thread can carry out an atomic operation at a time on the map.
Can anyone see any problems with this approach would I need to perform some kind of synchronization when I get the object from the hashmap
Thanks
Stephen
[Andrew: put the source code between [code] and [/code]
UBB tags]
[ June 15, 2004: Message edited by: Andrew Monkhouse ]