Hi all, Is it best to have the Data class a singleton, used through a remote reference by all clients, or is it best to have one instance for every clients ? If only one instance is chosen, then only one RandomFileAcces is used by all clients, which makes the th reading non-concurrent. If one instance is assigned to each client, the addition by a client of a new record to the database can be overwritten by another client (unaware of the previous addition). In both cases, the Data class will have to be slightly modified: collection RandomAccessFile in the first case and shared database state variables in the second. Am I completely wrong or does it make sense ?
I would only use one instance of Data for all clients, but I would avoid enforcing this relationship with the singleton pattern. Search this forum for somne great discussions on this. As far as "concurrency", all the methods in Data that interact with db.db are synchronized so the point is moot. Don't worry about it. Also, you will not need to modify Data in either case. -BJ Here is a link to an article about applying the factory pattern to getting references to remote objects: RMI Factory Pattern [ March 17, 2003: Message edited by: BJ Grau ]