Forums Register Login

Can i read and add records in 2 diff. instances?

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
This parrot is no more. It has ceased to be. Now it's a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 704 times.
Similar Threads
B&S: Opening database
question about assignment
Yes! Passed! 388/400
NX:Please analyze the DBAccess interface
NX: RandomAccessFile
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 01:27:23.