• 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

Valid Variable modifiers ?

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
transient - unserialized variable -- is it allowed in an interface ? why ?
strictfp - only for class and methods not for variables
volatile - what is it for ?
synchronized - methods only
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
transient is not allowed in interfaces. It only makes sense for instance fields. Fields in an interface are automatically public static and final.
___________________________________________________
"strictfp - only for class and methods not for variables"
True
____________________________________________
synchronized methods only
True
_____________________________________________
volatile is used to ensure that the changes to a primitive field, made by one thread, are always visible to others threads. It is like having synchronized the accessor and mutator methods of the field.
In the case the accesses to a variable occur through several threads, and they are not synchronized; declaring the variable as volatile --as an alternative to synchronizing the accesses-- might mean an advantage in performance.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also you can have one or more synchronized blocks within a method.
 
Robbie kyodo
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for some input. Do you allow transient and volatile in an interface or abstract ?
 
reply
    Bookmark Topic Watch Topic
  • New Topic