Hello
My intended locking mechanism uses two arrays:
one is an array of record token objects to lock on, one for each record in the database.
The other is an array of lock cookies, which are longs that identify a
client; also, one cookie per record.
I have two choices:A) use ArrayLists and don't worry about the size;
B) use arrays, but then I have to know the max nr of records.
Option A has the following drawbacks:-- performance is lower than with arrays, and you want the waiting time for other threads to be as short as possible
- and if I additionaly use
Java 5 Generics, the code is better but the performance will be even worse.
Option B forces me to assume a max nr of records. It does perform better, but I still think it's barbaric.
Will it be a problem if I just make an assumption about the max nr of records and let the app throw in the towel when that number is reached?
Have any of you encountered this dilemma? What are your thoughts on this?