Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: About thread safe

 
Bigwood Liu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Does anyone know why there is not synchronized any key word in DBAccess class? lock/unlock is not enough. There are many articles discussed that before.
Regards,
Damu
 
Jonathan Liu
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DBAccess is an interface, so there is no need to define synchronized here.
And it's your subclass's responsibility to implement this
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Damu,
Jonathan is almost correct.
Because DBAccess is an interface, it is illegal to mark any of it's methods synchronized. See the JLS.
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic