Hi, I tried to read/find records in one instance of a file and adding/modifying/deleting in another instance of the same file. There were no errors or exceptions. For example,
forRead instance can be used for read/find records. forWrite instance can be used for add/delete/modify records. Both were running parallely and did not give any exceptions. But is this a right way of doing? If yes, only 'forWrite' should have one instance and made synchronous. Please tell me if I am right. Thanks in advance, Rajesh
If memory serves, you can actually get two or more RandomAccessFile objects to work consistently against one single file. This critically depends on them sharing the same buffer, and I cannot remember how documented this actually was. Should you want to do this kind of thing, then I'd strongly encourage using the new I/O package over using a RandomAccessFile. File channels are safe against multithreaded access, and by mapping the database file to memory you can probably keep things relatively simple and highly concurrent. Relatively simple. Please note that (unless they've been changed since I did the test) the instructions explicitly require that you do not complicate the design for performance reasons. The original Data you've been given caters for multiple requests by simply synchronisation, effectively serializing any file I/O. My understanding of the requirements was, and still is, that you are supposed to keep it that way. - Peter
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Can i read and add records in 2 diff. instances?