• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

method : abstract - native - synchronized - strictfp

 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For doubt #1, see...

https://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
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Always look on the bright side of life. At least this ad is really tiny:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic