This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes synchronized and abstract Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "synchronized and abstract" Watch "synchronized and abstract" New topic

synchronized and abstract

ganesh subbiah
Ranch Hand

Joined: Nov 18, 2004
Posts: 39
I have a doubt why synchronized modifier be used along with abstract modifier with a method .

Thanx in Advance
Ganesh S
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

your question is not clear!!

Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
Olivier Lambert

Joined: Apr 30, 2004
Posts: 9
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" ...

Oli,<br />SCJP
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
You can't use other modifiers besides public, 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?

Mike Gershman
SCJP 1.4, SCWCD in process
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
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.

Don't get me started about those stupid light bulbs.
subject: synchronized and abstract