Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vector instances

 
Steve Brailsford
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have implemented the record locking control using a sync Vector in the Data class.
Just had a thought, when the request hits the server it spawns a thread, initially etc.. and creates a new Data object based on the location pathname. This would mean I get a new Vector object with every requests, this does not seem right does it.
Any help here please I would appreciate it. By the way using a Socket connection.
 
Sajid Raza
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need a single lock-tracking data structure that's shared between connections. I was wondering why you chose a Vector over a HashMap or HashTable with key = record number, and value = client id?
One question: since you're creating a new instance of Data for each request, how do resolve having multiple RandomAccessFile's with 'rw' permission on the data file operating in a concurrent manner?
BTW, is it legal for several RandomAccessFile instances to have 'rw' access to a file simulataneously?
 
Steve Brailsford
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sajid, thank for the comments.
I agree a single lock-tracking data structure such as making the Vector static, does that seem OK.
I am using a Vector over HashTable/HashMap because the server is in control of the locking not the client and so I dont need the client ID.
How could I control the updates through the Vector say when one client is using a different database to another client.
This I feel is my last hurdle to overcome before submission.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic