• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

About UrlyBird data layer design

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,everybody!
can someone comments on my design?
my version is 1.1.3,I study others' design,decide to cache all data in memory,put them in a arraylist(i am not sure it is right),recno start from 0,the record deleted also in it and have recno.
the most confuse me that the locking,I don't need record level,but I want It can multi read at the same time,so I want synchronize the arraylist when lock unlock update.Can someone give me some advice.

thx,sorry for my poor english
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Daming,

Don't worry about locking at the record level for each record, lock the whole list. The other threads can wait to read while you update a record. Locking at the record level is not necessary, so somehing like this, in the DB class, or the implementor:


I locked each record at the record level, and had a queue on the lists, and I lost marks, so keep it simple. Lock the whole list, modify, then unlock, simple. You don't have to have bullet proof code like DB2, and efficiency you don't have to worry about.

Hope this helps.

Michael
 
daming wang
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you,michael

my interface has not the declare:
public synchronized int lock(int recno) ;instead of
public int lock(int recno) ;
and I cache all the data in a arraylist,so I synchronized the arraylist
do you think it is proper
 
Michael Couck
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi daming,

Sorry about the long delay, don't look at these forums every day.

If I understand you correctly, your interface is:

And you don't want to break the method signature. But you can change some modifiers.
That is no problem, you can change the implementation of that method and include a "synchronized" modifier, no problem. But you said that you are synchronising on the list, that is also ok. Most of the people synchronised on the Data class, I think because it is easier. But synchronising on the list should be fine.

See ya

Michael
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic