• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Synchronized and Abstract modifiers

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
reply
    Bookmark Topic Watch Topic
  • New Topic