• 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

what is transient and volatile modifiers ?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,


i want to know what transient and volatile datatypes and use of them ?

abhijit
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Transient and volatile are not data types, they are modifiers. The transient keyword is used to indicate that an attribute should not be serialized when the object that contains it is serialized. The process of serialization refers to the transformation of an object into a stream of bytes. You usually do this to save off an object to disk or to send it across a network. Some classes are not serializable, such as a database connection, and they should be marked as transient when serializing an object that contains them in its state.

If a variable is declared volatile, then additional constraints apply to the operations threads that use the variable.
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey ...
i guess anthony has given a good explaination of "transient" .. in one sentence it's ... (both are keywords used with variables) .. a variable declared 'transient' is used to signal that this variable need not be saved on the disk or memory when the object is being saved ,....

and the keyword 'volatile' is used with variables to signal to the compiler that this variable may be changed by multiple threads and that it cannot take any shortcuts when retrieving the value in this variable ...
its someeeeeeeewhere related to 'synchronised' in method declarations
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic