Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Synchronized and Abstract modifiers  RSS feed

 
Yogesh Sawant
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am preparing for the SCJP 1.5 exam and have a basic question in one of the topics.

I read that we cannot use the abstract modifier along with the synchronized modifier for a method.

I understand that it won't make any sense to declare a method as both synchronized and abstract as what you put in a synchronized method is specific to the program logic and would not be right to leave the implementation details to the subclass. But apart from this, is there a more fundamental reason why it gives a compile error ?

Thanks in advance,
Yogesh.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If overriding method required to make the method synchronized it would
make it without breaking overriding rules. IMHO, making abstract method
synchronized is meaningless. A method has no body, so for what critical
section (data/operation) you are willing to have the method synchronized.



Thanks,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!