Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Remove synchronized from the data methods?

 
peter yuan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, everybody:
i just came to this wonderful forum and so happy to talk with you guys. u know, last week, i download the developer assignment and busy thinking the issues. i have to admit it is a great challenge to me and finally, hope to make the assignment well done at last.
some methods in the Data class has synchronized key word. and in my understanding, if we design the lock and unlock method, and implement them, the synchronized key word should be removed. and it is what Sun want us to do: synchronize the "write" function in the record level. Am i thinking right? hope to get reply from people staying here.
thank you very much!
peter yuan
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would not remove the Synchronized keyword form the Data class methods.
Read these posts
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=25&t=002257
Mark
 
morten wilken
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
if i understand correctly then, if you do not remove the synchronized from modify() then the entire database is locked for the duration of the modify method, and not just the record?
please correct me if im wrong
hmm... but perhaps this is desired, so another client cannot seek() something else in the middle of the modify operation.
sincerely
morten wilken
Originally posted by Mark Spritzler:
I would not remove the Synchronized keyword form the Data class methods.
Read these posts
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=25&t=002257
Mark
 
dean tomlinson
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi morten,
if i understand correctly then, if you do not remove the synchronized from modify() then the entire database is locked for the duration of the modify method, and not just the record?

the modify method, is where the physical writing of the new data occurs, so it is important that this is not done at the same time as any of the other syncd methods (add, delete, getrecord etc) otherwise the underlying database file could be corrputed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic