• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RandomAccessFile in 1.4.2

 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The RandomAccessFile in jdk1.4.2 supports synchronization. The links
[LINK]
http://java.sun.com/j2se/1.4.2/docs/api/java/io/RandomAccessFile.html
[/LINK]
specifies that..the mode in the constructor can have (new )following values

"rws" Open for reading and writing, as with "rw", and also require that every update to the file's content or metadata be written synchronously to the underlying storage device.
"rwd" Open for reading and writing, as with "rw", and also require that every update to the file's content be written synchronously to the underlying storage device.



Has anybody made use of "rwd" specified above?

If I use Java 1.4.2 and not use the "rwd" mode, will I lose mark?
 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found a similar discussion at
[link]
http://www.coderanch.com/t/184847/java-developer-SCJD/certification/NX-RandomAccessFile-mode
[/link]

From this discussion I feel that I am missing some crucial information.

In the API above what does this "synchronsouly" means in "content (or metadata) be written synchronously to the underlying storage device".

Does it mean two threads can't write simultaneously to the underlying storage device? If yes can't we make use of it in our locking mechanism?
 
Inuka Vincit
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basiaclly means you have to do queue writes(write one at a time). If it said asynchrounous(sp?) it would be thread safe. What this means to you is that when you use this you have to make sure every file read and write allows one access at a time by synchronizing.
 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Inuka
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic