This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method : abstract - native - synchronized - strictfp

 
ankur rathi
Ranch Hand
Posts: 3830
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is mention on page 88 of K&B that :

abstract method can't be marked as synchronized , strictfp or native . all of this modifier describing something about the implementation of a method & abstract method doesn't say anything about implementation .

My doubts are :

1] strictfp describe something about implementation & abstract not ... then how is permitted in case of class .

strictfp abstract class A {}

2] How synchronized keywork describing anthing about implementation . It is just like that if one thread is using then other can't use .



please help me ...
thanks a lot ...
[ January 13, 2005: Message edited by: rathi ji ]
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For doubt #1, see...

http://www.coderanch.com/t/398241/java/java/interface-abstract-or-strictfp

For doubt #2, note that the synchronized keyword is not passed via inheritance. Since abstract methods defer implementation to a subclass, it would do no good to mark them as synchronized.

Ref: http://www.janeg.ca/scjp/threads/synchronization.html
[ January 13, 2005: Message edited by: marc weber ]
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, none of these modifiers are retained when a method is overridden (i.e., when an abstract method is implemented), so it would do no good to use any of these modifiers along with abstract.

This can be verified using reflection...


NOTE: The output of this code makes me question the oft-quoted statement, "the synchronized modifier is not passed via inheritance." I think it's probably more accurate to say, "the synchronized modifier is not retained when a method is overridden." Comments?
[ January 13, 2005: Message edited by: marc weber ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic