• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

synchronized and abstract

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a doubt why synchronized modifier be used along with abstract modifier with a method .


Thanx in Advance
Ganesh S
 
Ranch Hand
Posts: 1880
Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
your question is not clear!!
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't define a method both abstract and synchronized. Abstract implies that your method has no body while synchronized says that the body of your method is "secured" ...
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't use other modifiers besides coderanch, protected, and private with abstract because they are implementation details, not client interface specifications.

What if a better implementation of your method used individual synchronized blocks of code or you found a thread-safe algorithm that didn't need locks at all? Why force the entire method to be synchronized by inheritance?
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
take up a dictionary and look up the meaning of the words 'doubt' and 'question'.

doubt != question, therefore your statement does not compile.
It caused a compiler error in my brain of which this is the output so I am unable to help you further.

Stack overflow, nullpointer out of range error, reset universe.
reply
    Bookmark Topic Watch Topic
  • New Topic