This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes what is transient and volatile modifiers ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "what is transient and volatile modifiers ?" Watch "what is transient and volatile modifiers ?" New topic
Author

what is transient and volatile modifiers ?

Abhijeet Deshmukh
Greenhorn

Joined: Aug 09, 2004
Posts: 6
hi,


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

abhijit
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
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.
Mahesh Bhatt
Ranch Hand

Joined: Sep 15, 2004
Posts: 88
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


Impossible is I M Possible
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: what is transient and volatile modifiers ?
 
Similar Threads
keywords
volatile and transient Details
Transient and volatile variables ?
Please Help
variables difference