• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

make server and db classes threadsafe. How??

 
david hu
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
it's mentioned that we must make server and db classes threadsafe. How to do it?
Since we have to implement the lock() method, does it mean once we implement the lock method, then the db class is threadsafe?

Thanks a lot!
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thread safety is about making sure that multiple clients do not affect each other badly.
Simply put, If I call a method on the Data class, I want to make sure that no other client is also running that method at the same time. It is not threadsafe.
That's what the synchronized keyword handles.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic